TinySensor circuit diagram |
- It uses my 'port' to ATtiny of Maniacbug's excellent RF24 and RF24Network libraries for the NRF24L01 radio.
- It runs for over a year on only a single AAA battery with an NCP1402 3.3v step-up converter.
- It is field-programmable using the TinySafeBoot bootloader and the Arduino IDE, as described previously.
- It costs about €15 per node when prototyped on padboard with breakout boards for the radio and voltage converter.
- RF24 and RF24Network tweaked for ATtiny and Raspberry Pi.
- Modified Arduino SPI library providing SPI emulation on ATtiny.
- A DHT22 library (forked from here) and also tweaked for ATtiny, by removing floating-point.
- Sketches to test the board and set the network address (in EEPROM) and run the hardware in the field.
- A Raspberry Pi program to receive the data and dump it into the database.
Nice blog :) Been following with great interest.
ReplyDeleteRegarding the SPI emulation, do I put this in my libraries folder or elsewhere, and will it interfere with 328 based projects?
You put it in your sketchbook/libraries folder. It's compatible with both ATMega and ATtiny.
DeleteHi, this is great work, and thanks for sharing it!
ReplyDeleteI'm trying to get RF24 working on ATTiny85, so I can have just a very simple temp and humidity node. I basically have it working with your modded libraries with the hellotx sketch, but it only works about 1 in 30 times - it says it failed, and the receiver doesn't get it either. In contrast, the same program and libraries work 100% on an Arduino Pro 3.3V. I've just got it running on a breadboard, I've tried injecting more 3.3V power, about the only thing I can think of is that it's using the 8MHz internal oscillator, but it seems you're doing the same.
Any idea what the problem might be? Places to look?
Thanks very much,
Joel
I had great difficulty getting started until I soldered a decoupling capacitor across the power pins of the radio. (It looks like this is missing in the circuit diagram above.)
DeleteThe first time round I used a 10u electrolytic capacitor; in the final circuit I used 100n.
Hope this helps!
I put a 10uF across the power pins of the Tiny, which are the same power pins as the radio; does it need to be right on the radio module itself? Mind you the radios were very cheap, maybe because they skimped on parts...
DeleteThanks!
Wikipedia says this about placement: "A transient load decoupling capacitor should usually be placed as close as possible to the device requiring the decoupled signal."
Deletehttps://en.wikipedia.org/wiki/Decoupling_capacitor
So yeah, if you can manage it, solder it onto the module itself.
OK, I soldered a 10uF 25V onto the pins of the module which is as close as I can get to the chip itself. Now it seems to be working almost exactly every 4 goes.
ReplyDeleteAnother thing I notice is that the Pro Mini version sends the time at exactly 1000ms, ie the ping received is 2000,4000, etc. But the tiny version, which I set at interval of 1500ms, loses a few ms each time. Maybe it's taking longer to do network.update(), or this function isn't operating correctly?
Without knowing more about your setup, I can't really comment. You could try replacing the ATtiny with an ATmega on the breadboard and see if that made a difference to the timing or the reliability.
DeleteYou could add more smoothing capacitors to your 3v3 supply (where is that coming from?). I would imagine there is still a lot of noise around the breadboard (and jumpers which you must have used to connect the radio).
I'm pretty sure network.update() is working fine. It may be that it has to do several retries to get the message through.
You could change the data rate or the number of retries to see if it makes a difference. See the class docs here:
https://maniacbug.github.io/RF24/classRF24.html
You could also read the comments on Maniacbug's original blog post here:
http://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/
Yeah, thanks, I'll try doing it on a protoboard and see if that works better. Probably dodgy breadboard connections.
DeleteI've got an ATmega running a radio in a very similar fashion, flawlessly. They also run off the same 3.3V power from USB via a regulator on the USBasp. Then I plugged in an additional 3.3v external source but that hasn't helped.
So besides some dodgy wires, the main difference is in the chips themselves and the way they run - it might be the same sketch, but the ATtiny compiled code is much smaller, as well as being a different architecture and running at half the clock speed.
Will let you know how it goes, thanks for your help!
Actually I think the architectures are very similar, the difference in size is due printf() being excluded on the tiny.
DeleteYou could also try powering it from a battery via a 3v3 LDO regulator. This might isolate it from one source of noise...
Hi, sorry to keep bothering you. I've moved away from the ATTiny85 for the moment and focused on getting everything else to work with an atmega. I've got all of your code running and recording data except the viewer with leiningen/clojure, which I'm not familar with. Is this working for you as a fresh git clone? First, the jar has no main class, so I added that to the project but there are problems building. I tried running it in the IDE on my mac but I get errors that appear to be due to differing compiler/runtime versions. What is the local jvm dir supposed to do? I had to create an empty dir for it to compile, but even if I symlink it to the current JAVA_HOME it doesn't fix my problems.
DeleteThanks
Joel
Huh, interesting. Whichever way lein is invoking the Clojure compiler, you have to give it :requires as vectors not lists. (I'd been running this from IntelliJ with the Cursive plugin and it was all fine there.)
ReplyDeleteAnyway, try it now, it now works for me from "lein run".
I switched from my mac to Linux Mint VM as the mac was having weird errors (and is old). I don't know if I don't have the right versions but it won't compile or run. If you run it just appears to hang. On compilation, there are a few errors and then it just stops. No CPU, just won't return to prompt.
Deletejoel@joel-mint-VirtualBox ~/src/TinySensors/sensing $ lein compile
Compiling sensing.ui
Reflection warning, seesaw/table.clj:83:9 - call to getColumnClass can't be resolved.
Reflection warning, seesaw/table.clj:64:9 - call to insertRow can't be resolved.
Reflection warning, seesaw/table.clj:59:9 - call to addRow can't be resolved.
Reflection warning, seesaw/core.clj:937:5 - call to setLayout can't be resolved.
Reflection warning, seesaw/core.clj:1489:68 - call to java.lang.Integer ctor can't be resolved.
Reflection warning, seesaw/core.clj:1489:68 - call to java.lang.Integer ctor can't be resolved.
Reflection warning, seesaw/core.clj:1489:68 - call to java.lang.Integer ctor can't be resolved.
Reflection warning, seesaw/core.clj:1489:68 - call to java.lang.Integer ctor can't be resolved.
Reflection warning, seesaw/core.clj:1731:53 - call to setWidth can't be resolved.
Reflection warning, seesaw/core.clj:1731:69 - call to setPreferredWidth can't be resolved.
Reflection warning, seesaw/core.clj:1733:51 - reference to field getWidth can't be resolved.
Reflection warning, seesaw/core.clj:1907:17 - call to javax.swing.SpinnerNumberModel ctor can't be resolved.
Reflection warning, seesaw/core.clj:2513:18 - call to paintComponent can't be resolved.
Reflection warning, seesaw/core.clj:2617:9 - reference to field invalidate can't be resolved.
Reflection warning, seesaw/core.clj:2617:9 - reference to field validate can't be resolved.
Reflection warning, seesaw/core.clj:2617:9 - reference to field repaint can't be resolved.
Reflection warning, seesaw/core.clj:2634:5 - call to setTransferHandler can't be resolved.
Reflection warning, seesaw/core.clj:2634:5 - reference to field getTransferHandler can't be resolved.
Reflection warning, clj_time/core.clj:577:10 - reference to field getDayOfMonth can't be resolved.
Reflection warning, clojure/java/jdbc.clj:418:16 - reference to field executeBatch can't be resolved.
Reflection warning, clojure/java/jdbc.clj:420:13 - reference to field getUpdateCount can't be resolved.
Reflection warning, korma/db.clj:142:31 - call to endsWith can't be resolved.
Reflection warning, korma/db.clj:204:5 - reference to field printStackTrace can't be resolved.
Reflection warning, korma/db.clj:206:21 - reference to field getNextException can't be resolved.
Reflection warning, korma/sql/engine.clj:84:42 - call to indexOf can't be resolved.
Reflection warning, sensing/data.clj:19:13 - call to plus can't be resolved.
Reflection warning, sensing/data.clj:59:57 - reference to field toLowerCase can't be resolved.
lein version shows: Leiningen 1.7.1 on Java 1.7.0_60 Java HotSpot(TM) 64-Bit Server VM
What versions are you running?
Thanks
Joel
(You could try upgrading lein. If it can't find the Java APIs, something is badly messed up...)
Deletesteve@lenovo:~/src/Sensorhub/sensing$ lein -v
Leiningen 2.0.0 on Java 1.7.0_55 Java HotSpot(TM) Client VM