Post topics, source code that relate to the Arduino Platform

User avatar
By longinus
#1663 As a quick first project using the ESP8266, I've made a temperature and humidity logger controlled by an Attiny85 (using the arduino tiny core). Also works on a regular arduino (atmega328 based).

Image

I wanted to make a sensor that would be cheap and last a long time when sporadically logging stuff.
Unfortunately I was only fully successful in the first part... but it does work!
If anybody is interested, the code and very simple schematic is on my github.

It logs the temperature, humidity and internal voltage every 5 minutes, and sends the message to an UDP port in my server. The received message (a JSON string) will be forwarded to my MQTT broker (and from there it's logged, displayed, etc).

When it's sleeping it should use very little power. The attiny85 plus the voltage regulator (MCP1700) use very little, just under 8uA. But the ESP8266 module, even with the CH_PD enable pin low will still draw about 30uA. Slightly annoying; I probably should have used a mosfet or something similar to source power to the module.

But what really uses up quite a bit of power is that it takes about 10 seconds for the module to fully wake up, connect to my wifi and send the data over UDP.
I'm using some quite long delays in my code... it's possible to do it faster, but I've ran into different issues when I rushed commands over when the module wasn't ready.

I would love if there was a better way to know when the module is ready... but then if the module used SPI, I probably woulnd't be able to use an attiny85.. :)

The code will definitively not be useful out of the box for anybody, but it should be trivial to change the UDP server/message.
I developed the code in a regular Arduino (with the debug line uncommented in the code), then when I was sure it was working I just passed it over to attiny85. (notice the 2 sets of pinouts defined in the top of the code).

If you have any comments or question I would be glad to help!
User avatar
By igrr
#1666 Great work!
I have recently implemented wifi connection status notification in the firmware, it appears as an unsolicited return code (+CWSTAT:<value>).
In my case the module usually connects within 2 seconds from power up.
The tricky thing is to discard all the garbage that comes from the bootloader without discarding the CWSTAT messages that follow. Maybe adding "firmware ready" status indication via GPIO2 pin will help?
User avatar
By al1fch
#1667 Thanks longinus

I'll look at your code to see how you deal with sleep/awake

Here what I'm doing with CH_PD (UNO + ESP8266 module firmware 0922 + sending just one incremented interger to ThingSpeak (HTTP GET)

(incremented integer just to 'see' lost ones..!!!.... )
fast written code, comments curently in french
You do not have the required permissions to view the files attached to this post.
User avatar
By longinus
#1687
igrr wrote:Great work!
I have recently implemented wifi connection status notification in the firmware, it appears as an unsolicited return code (+CWSTAT:<value>).
In my case the module usually connects within 2 seconds from power up.
The tricky thing is to discard all the garbage that comes from the bootloader without discarding the CWSTAT messages that follow. Maybe adding "firmware ready" status indication via GPIO2 pin will help?


A awesome, I'll give your firmware a try! Haven't had time time to try it out yet.
The status notification will definitely help.... I think I'm ending up waiting about 5 seconds on power up, but it's definitely too much.
The idea of using GPIO2 is interesting! Maybe as some sort of CTS signal too, toggled high when the module processed the previous command (and usually returned something over serial).