ESP8266 + battery + temperature sensor?

I've read about the ESP8266 and it may be a perfect fit for my project but I am not quite sure. Maybe you can help me determine if the ESP8266 is good for this:

  • A stand-alone device (not connected to an Arduino) link
  • battery-powered (minimum battery life 30 minutes)
  • bearing a temperature sensor
  • programmable with a Arduino-like IDE link
    Is one of the ESP8266 suitable for this?
    From everything I read about the ESP8266 I am not sure whether this works out power-wise and pin-wise. If so, which board would you recommend?

(Background: I want it to send temperature data over wifi to a nearby computer every 30 seconds or so for about half an hour.)

If you use a I2C sensor you have enough pins to run even a ESP-01.
I will recommend you for further developments to use a ESP-07 or ESP-12.

For I2C temperature sensors examples:

  1. MCP9808 - high precison temperature sensor:
    http://www.esp8266-projects.com/2015/02/part3-esp8266-cheap-and-dirty-basic.html

  2. LM75 - less accurate but standard one:
    LM75 – I2C temperature sensor driver – CBDB

A quick battery solution:

I hope it helps you developing your project.

The ESP8266 runs around 70ma. It does spike up to 200ma if you have an oscilloscope that will catch it, but just assume 70ma constant.

So with a couple 2200mah, AA alkaline batteries for 3V it will be right close to 30 minutes hours. You would want a larger lithium battery like trackerj's link shows to ensure you get a full 30 minutes

There is code available for using the more popular DS18B20 temperature sensor with the ESP8266 as well. The DS18B20 appears to be comparable to the MCP9808.

Chagrin:
The ESP8266 runs around 70ma. It does spike up to 200ma if you have an oscilloscope that will catch it, but just assume 70ma constant.

So with a couple 2200mah, AA alkaline batteries for 3V it will be right close to 30 minutes -- probably a little under. You would want a larger lithium battery like trackerj's link shows to ensure you get a full 30 minutes.

There is code available for using the more popular DS18B20 temperature sensor with the ESP8266 as well. The DS18B20 appears to be comparable to the MCP9808.

If I understand right what you say you assume that a full battery charge will work only 30 minutes? If is so, is not true, it will run for many days. And if you use also deep sleep even more that that.

This is how power consumption looks for ESP-07 module running the MCP9808 temperature sensor code, WebServer + upload data to thingspeak.com.
And a full battery drain from about 70% capacity.

Thanks, trackerj, I will look into these links!

trackerj:
This is how power consumption looks for ESP-07 module running the MCP9808 temperature sensor code, WebServer + upload data to thingspeak.com.
And a full battery drain from about 70% capacity.

Would you mind sharing the code for this example? Did you upload the code with a modified Arduino IDE as described in the article I've linked in my original post?

farblich:
Thanks, trackerj, I will look into these links!

Would you mind sharing the code for this example? Did you upload the code with a modified Arduino IDE as described in the article I've linked in my original post?

You have the code in the article above about MCP9808 - Temperature Logger.

All code is in LUA, You need to load NodeMCU firmware on yor ESP Module:

For uploading data on thingspeak just add to the MCP9808 example from the above the below code:


-- Get temperature and send data to thingspeak.com
function sendData()
-- conection to thingspeak.com
print("Sending data to thingspeak.com")
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end)
-- api.thingspeak.com 184.106.153.149
conn:connect(80,'184.106.153.149')
conn:send("GET /update?key=ADDYOURKEYHERE&field1="..tp.."HTTP/1.1\r\n")
conn:send("Host: api.thingspeak.com\r\n")
conn:send("Accept: /\r\n")
conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")
conn:send("\r\n")
conn:on("sent",function(conn) print("Closing connection")
conn:close()
end)
conn:on("disconnection", function(conn) print("Got disconnection...")
end)
end

-- send temp data every 1 min to thingspeak.com
tmr.alarm(1, 60000, 1, function() sendData() end )


trackerj:
All code is in LUA, You need to load NodeMCU firmware on yor ESP Module:

Thanks. After reading this article I was under the impression that I could program the ESP8266 just like an Arduino. Is this correct?

I realize the LUA code may work, too. I am just wondering if this could be done in Arduino Code, too.

farblich:
Thanks. After reading this article I was under the impression that I could program the ESP8266 just like an Arduino. Is this correct?

I realize the LUA code may work, too. I am just wondering if this could be done in Arduino Code, too.

It is true, you can use also Arduino IDE to upload your code, as stated in that above article.

I built this project, ESP-01 and a single DS18B20 temp sensor using the LUA sketch:

ESP-01 with a single DS18B20 (no arduino):

Uploaded temp reading once every 10 minutes to ThingSpeak

ran for 64 hours on 3 x AA nicads (with 3.3v voltage regulator inline)

ran for 59 hours on 2 x AA nicads (no voltage regulator)

Awesome, thanks everyone. I have ordered the following components:

Shipping will take a couple of weeks. I'm thrilled to see whether I can get it to work!

farblich:
Awesome, thanks everyone. I have ordered the following components:

Shipping will take a couple of weeks. I'm thrilled to see whether I can get it to work!

Looking forward to see the result :slight_smile:
What's the temperature range that you want to monitor?

OMG, OMG, opened the link ... never ever seen in my life such a mess like in the links provided above :)))))
WTF, 1pcs DS18b20 Waterproof Temperature Sensors Thermistor Temperature Control H1E1, Resistance Sensor, analog sensor ?? WHAAT? a, it's good, has also mixture...good...asphalt one?

Are you sure they know what they are selling and you what are you buying from them?

I have for selling, 2 bucks only, free shipping, a Low Orbit Geosynchronous underwater satellite capable of Mars terraforming. or Bounty, your choice.

</rant mode>

Be carefully with this kind of sellers...just my 2 cents.

A, and why AA Batteries?

trackerj:
Are you sure they know what they are selling and you what are you buying from them?

Absolutely not, it's my first time ordering from this site. An experiment for sure!

What can I say? Many of the sites that are linked here are in the U.S. and shipping is expensive (I'm in Europe). I admit that ordering from such a site is risky. On the other hand, it's just a hobby project and the components are cheap so I figured it's worth a try. The components listed above cost $8 total. If they ship and work I'm happy. If not, I've learned something.

trackerj:
and why AA Batteries?

It's supposed to be a stand-alone device. AAs are easy to come by. If I got you right, your solution linked above involved an additional board just for charging a 3.3V battery. sp_mike's post suggested that the ESP8266 can be powered with two standard AAs. So I thought I'd go for the simpler solution.

farblich:
Absolutely not, it's my first time ordering from this site. An experiment for sure!

What can I say? Many of the sites that are linked here are in the U.S. and shipping is expensive (I'm in Europe). I admit that ordering from such a site is risky. On the other hand, it's just a hobby project and the components are cheap so I figured it's worth a try. The components listed above cost $8 total. If they ship and work I'm happy. If not, I've learned something.It's supposed to be a stand-alone device. AAs are easy to come by. If I got you right, your solution linked above involved an additional board just for charging a 3.3V battery. sp_mike's post suggested that the ESP8266 can be powered with two standard AAs. So I thought I'd go for the simpler solution.

OK, now I understand. Wish you luck and looking forward to see the result.

Li-ion cells will give you a longer running time range and flexibility but of course some Ni-Mh AA rechargeable batteries are working ok. Nobody said cannot be charged separatelly. Ni-Mh , Li-ion or whatever.
And keep in mind Ni-Mh cells are only around 1.2V fully charged.
If you was asking me about the AA solution, I would use 3xAA for a better discharge range.

What temperature range do you need to monitor and how accurate you want to do it?