Notifications
Clear all

Is connecting to Wifi quickly an option here? Programing advice  

  RSS

garnold
(@garnold)
Trusted Member
Joined: 1 year ago
Posts: 68
2020-02-10 8:47 pm  

I'm working on a very simple MQTT project. The device will have two buttons and depending on the button a different message is sent via MQTT. Nothing special here with this project so far. The issue is that these devices will be sitting on desks for a rather long time and need to run off of battery. To conserve some juice I planned on making the Arduino with ATMEGA chips rather then using a full development board. I was also thinking of adding deep sleep into the mix to add to the power saving but my worry is that once a button is pressed it will take to long to connect to WiFi each time and post the message. Even if I hard coded some of the Wifi settings I think it will still take to long but wanted to ask others for their ideas. Another thought was to drop the WiFi idea all together and use RF to a main controller machine that takes the RF call and converts it into a MQTT message. This is an option but wanted to explore the WiFi option first. Could I please get some programming concept ideas? Thank you!


Quote
NewburyPi
(@dale)
Estimable Member
Joined: 1 year ago
Posts: 102
2020-02-10 9:27 pm  

Good one... I'm looking forward to hearing some responses. I've mused on this one in the past and I always come back to, "How does the sleeping dog wake up." I read up on a technology called ESP Now that seems to reduce the power consumption when it is awake, but still how do you wake it. Give it an internal wake up call, but how often. 

There's a fellow named Kevin Darrah who has built a very low power ESP8266 board (trigBoard). His videos are low power focused. Maybe some nuggets there.

--
Dale


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 1 year ago
Posts: 303
2020-02-11 10:34 am  

@garnold

A very easy test could indicate if the time from button press to some action being performed is acceptable.  Theres sleep, deep sleep and off.  Why not test for the worst cast of off.  Create a simple sketch to send your choice of mqtt message via wifi or RF or whatever  Have one switch to toggle a pin high or low to indicate one of your two states and another switch to switch the Arduino on.  Your sketch is then automatically run and you can then see if the time it all takes is OK for you.   You may shave a tiny bit of time off by waking from a sleep, but not so much I think.   And don't forget to post your conclusions right here. ? 


garnold liked
ReplyQuote
Pugwash
(@pugwash)
Prominent Member
Joined: 1 year ago
Posts: 970
2020-02-11 11:19 am  

@garnold

I have some remote sensors working with naked ATmega328 chips, which has dropped the power consumption from about 30mA to 0.6mA. These are now powered with a single 18650 battery at 3.3V. The remotes are timed to wake up out of deep sleep and transmit data, but could also be awakened with a button attached to an interrupt pin!

Just an idea!!


ReplyQuote
garnold
(@garnold)
Trusted Member
Joined: 1 year ago
Posts: 68
2020-02-11 9:07 pm  

@pugwash

My plan was to use the same chips to keep the power down as well. How are you connecting those chips to Wifi?


ReplyQuote
Pugwash
(@pugwash)
Prominent Member
Joined: 1 year ago
Posts: 970
2020-02-12 9:24 am  

@garnold

I am using the nrf24l01 RF breakout board because WIFI won't hack it, too many walls between the remote and my WIFI router.

This is the prototype:

1276 IMG4255

I am using the Lowpower.h library. But you would probably be better off using the AVR/WatchDog library with the wakeOnInterrupt function.


ReplyQuote
garnold
(@garnold)
Trusted Member
Joined: 1 year ago
Posts: 68
2020-02-12 2:41 pm  

@pugwash

So let me ask another question, it looks like for me to get WiFi going with an Arduino board I would need to introduce an ESP8266 into the mix. Unless I purchase an Arduino board that has WiFi on the board already. I do have a mkr wifi 1010 that I bought at one point but found it much harder to program the WiFi then with an 8266. 

@pugwash, it looks like you changed from WiFi to RF to get your project going. With RF I'm sure I would have no timing issues at all coming out of sleep mode and I could produce a rather low power solution making the unit from parts myself. So going naked chip with RF certainly is a possibility I will explore to earn more about creating my own unit.

So now for the question, if I need an 8266 anyway, maybe I should look into ESPNOW? Has anyone messed around with that? It first I thought it was just for ESP32 units but apparently I'm incorrect and it can be used on ESP8266 units. Since I have a bunch of those around I think I might take that approach. I'll certainly test this and post my results here. Any feedback from folks that have tried ESPNOW would be wonderful!


ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 10 months ago
Posts: 380
2020-02-14 6:57 pm  

@garnold

I'm experimenting with MQTT on ESP's now (ESP32) but I'm not into deep sleep yet...

If you go the WiFi route, I suppose an ESP programmed under ESPduino would be enough by itself ?

Eric


ReplyQuote
garnold
(@garnold)
Trusted Member
Joined: 1 year ago
Posts: 68
2020-02-14 7:11 pm  

@zeferby

I've been using the

HiLetgo ESP-WROOM-32 ESP32
HiLetgo ESP8266 NodeMCU CP2102 ESP-12E

And some Wemos D1 Mini's to play around with.


ReplyQuote