× General topics about hardware.

ATMega328 internal resonator for MySensors sensor?

9 years 5 months ago #1120 by mrbwa1
Hello all,

I have successfully boot-loaded some bare 328p chips and have been doing some experimenting with them. I haven't had the free time to hook up the NRF24L01 to them yet, but once the chip is bootloaded, it's as simply as connecting to the right pins (as in ATMega328p pin 13 is not Arduino pin 13 and uploading a sketch with an FTDI.

On thing I haven't tested is the variability of the internal oscillator when it comes to timing. I don't expect to be using it for mission critical stuff, and it seems stable enough just playing with some timings for LED blinks, so it should be fine for a sensor.

Here is the easiest setup I have found to get going using an Arduino UNO to bootload and an FTDI to program: www.gammon.com.au/breadboard

Of course, my FTDI board has a DTR line instead of RST, so I had to figure out how to wire it up (DTR can got to the RST spot in the linked setup and it works fine)

The biggest drawback I see is that once you have a working setup, you will then either need to design a custom PCB or solder everything to perfboard. There is really no cost savings to this setup over using a Pro mini with LED/Voltage Regulator modification unless you have a stack of perfboards, ATMega chips, resistors and decoupling caps.

Bare chips alone are alonr $2 from chine and $3+ from electronics suppliers (I often through one in when I need to order components to meet a $5 minimum order when it would cost $5 for me to get a handful of individually packaged components from say eBay.

The only real advantages I see are the possibility of jumping to an ATMega1284p chip for more inputs and 16k or RAM/128k Flash. It's kinda of a halfway to a Mega (only 2 UARTS, 3 interrupts and 8 analog inputs) in a DIP package. The 16k ram would be killer though. Other than that, perhaps making a setup with a couple 328ps chained together via i2c might be interesting.

If you are interested in more, let me know and I can try and work some more on specific sensors when time permits (Time is always working against us, isn't it?)

Please Log in or Create an account to join the conversation.

9 years 5 months ago #1122 by wergeld
I actually just built one using Gammon site's information. I have it running at 8 MHz and off of 2 AA batteries plugged directly into the ardunio's VCC. This is only ~3.1 V. I then am using a very basic thermistor temp sensor (basically a voltage divider) and an nrf24+ radio. In the mySensors sleep mode (power down) i draw 50 microAmps. And during reading of sensor/transmission it jumps to 15 mA - but only for about 100 ms. Calculated that I could get about 4 years of battery life - in a perfect world of course.

I am using the internal resonator and will drop this down to 1 Mhz as well. Only components I have on my system are some de-coupling caps, radio, and thermistor. No voltage regulator or LEDs. The LEDs dont really use all that much compared to an inefficient voltage regulator like the one on the pro minis.

Hardest part about building this sensor was calibrating the beta coefficient for my particular thermistor.

Please Log in or Create an account to join the conversation.

9 years 5 months ago #1124 by mrbwa1
I had initially started out trying to build a weather sensor into the housing of an outdoor solar LED light. My idea was to run the raw voltage from the Lipo into the ATMega then use a regulator on a digital pin so i could power the radio off an on as needed with the idea of eventually replacing the NRF24L01 powered from a pin by an ESP8266.

With the intro of the ESP8266 Arduino, I have been rethinking my strategy a bit as I have some nice low draw voltage regulators, so if I could get the ESP8266 to sleep itself, combined with a solar charging circuit, I may be able to make a viable battery-powered ESP.

Voltage regulator really are a pain, because most aren't really designed with ultra-low power consumption in mind. It's almost cheaper to boot a Lipo to 5V and run a circuit off that I have some of these, but I have to put together a pretty decent sized order for the $5 shipping from Mouser to be worthwhile:

www.mouser.com/ProductDetail/Microchip-T...NMMPEB66r2rMQw%3D%3D

Gammon has some great stuff on some really really low power circuits, but at some point you are lowering power consumption below the self-discharge rate of the battery in use. Once your power consumption is equal to self-discharge, there is no practical reason to save even more power.

You also have to decide when designing a circuit how "correct" you want it to be. For instance, the NRF24L01 will operate from 1.9-3.6V, so you could feed a lipo to it through a diode for a max of about 3.5 v (4.2V -0.7V diode drop)and use the voltage circuit to monitor battery level. A few sensors do starte getting flaky with less than 3.0V lie a DS18b20 so you could rely on the software to flag the battery as toast at 3.7V (3..0 after the 0.7V diode drop). I would never do this on a production-ready project, but for a quick and dirty solar lipo powered project it might just work.

I also agree with LEDs. The problem with LEDs are always on leds on boards. Additionally, the basic blink sketches really miss out on an opportunity. There is no reason to power an LED on for more then 10ms in my experience. If you need to communicate something, you can use a coded pattern of blinks (1 blink every x # of seconds = OK, 2 blinks = check battery, etc).

Please Log in or Create an account to join the conversation.

9 years 5 months ago - 9 years 5 months ago #1125 by PaulRB
Hi mrbwa1 and wergeld, and thanks for trying this out for me, and reassuring me that it will work! I have some atmega328 and an ftdi adaptor on order.

mrbwa1 wrote: The biggest drawback I see is that once you have a working setup, you will then either need to design a custom PCB or solder everything to perfboard.

Well, don't you have to do that anyway, even if using a Pro Mini? OK, you could solder some wires to the Pro Mini, but what's at the other end of the wires?

I plan to attach some/all of the sensors I mentioned in my OP (BMP085, SHT21...). Also windspeed, direction & rainfall sensors (the cheap ones you can buy on eBay as replacements for common inexpensive weather stations). The SHT21 has a min voltage of 2.1V, versus the 1.8~1.9V minimum for the atmega, nrf24l01+ and the BMP085, so that may be the limit the battery life, but that's better than dht11/22 which seem to need around 3V.

I also plan to experiment with esp8266 in the future, but everything I have read so far seems to say that its not a good idea for battery powered sensors because it draws so much current. So I plan to use nrf24l01+ & Arduino for battery powered sensors for the time being. If you figure out a low power sleep, do let us know!

wergeld wrote: In the mySensors sleep mode (power down) i draw 50 microAmps. And during reading of sensor/transmission it jumps to 15 mA - but only for about 100 ms. Calculated that I could get about 4 years of battery life - in a perfect world of course.

Excellent news! I plan to use low self-discharge NiMh cells, but even they won't last anything like that long. Makes going for 1MHz seem a little uneccesary! I was considering 2xAAA vs 2xAA though.

Please Log in or Create an account to join the conversation.

9 years 5 months ago #1126 by mrbwa1
The only problem I see with the wind speed/direction sensors is having calibration data to interpret the voltages output by those sensors. You may need to calibrate the. Yourself which could be hard. If the calibration data is available, then you should be good to go.

Please Log in or Create an account to join the conversation.

9 years 5 months ago #1128 by PaulRB

mrbwa1 wrote: If the calibration data is available, then you should be good to go.


Here is a link to a page about these sensors. There is some calibration data, these are "cheap and cheerful" sensors!

Please Log in or Create an account to join the conversation.

Time to create page: 0.248 seconds

Forum latest

  • No posts to display.