Pulsewidth labs is a sort of division of MAGFest, full of people who love excessively technical
solutions to problems that are facing MAGFest.
And one of those problems is asset tracking.
And really we just want to know if something is in this room, or that room or is it in
the hotel or is it at the warehouse and just kinda get a very high level picture.
So, no real-time localization or anything like that.
And we all had different ideas of what we wanted to do to solve this problem.
Some people wanted to do LoRA and some people wanted to do RFIDs.
And I chose the probably incorrect route of nothing else but an esp8266.
One of the biggest problems that we're gonna run into is battery life.
And thankfully youtuber Andreas Spiess has already kinda looked into this.
He's done a lot as far as being able to show and test a bunch of ESPs to show they can
last about a year on two AAs.
For us, that's not enough but thankfully we don't have to do everything the same way he
did.
Normally when you're using an ESP8266, the way it works is you use wifi to connect to
a home router the home router will let you log on with a fairly complicated handshake
back and forth.
You'd get an IP and then using that IP address through the router you can talk to the internet
and even send data to the cloud.
And that's all fine and dandy, and that's exactly what Adreas did, but that's not going
to work for us cause well #1 many times there's no internet at all.
So, how are we gonna work with these things without that?
The other, bigger problem is that when operating in this sort of way, well.
Well, I guess you should know about something called deep sleep.
Deep sleep is something on the ESP8266 which allows it to go kind of dorment and during
deep sleep it uses about 20 uA of power, which is a very small amount of power.
Then, when it wakes up, it can be set to wake up at a specific time.
It uses a lot of power while it's doing this exchange.
In transmitting data to the internet.
It actually uses about 70 milliamps and that's a lot of power.
And once it's done it can go back to sleep and everything's fine.
Back down to the nice 20 uA level.
But the problem comes in how long does this take?
It means any time you want your ESP to wake up and do something, it has to do all of that.
And tests have really shown it's somewhere between 6-10 seconds.
And that's just a long time, so we're gonna have to make that faster.
Now, because this the only way that's supported in the ESP NONOS SDK, and by extension arduino
and pretty much any of the libraries anyone else uses, we're going to have to find a different
way.
In come Victor, or PVVX.
And he's somebody who's taken great lengths, like herculean efforts to reverse engineer
the ESPs SDK and understand how it works and take it apart and to be able to allow people
to do stuff with it that it was never intended.
But his work seems largely unknown until more recently, at least to me.
His SDKNoWifi predated my ESP SDK without wifi by over a year and he did a better job
than me to begin with!
But what I'd really like to focus on is this amazing effort he's made in the MinESPSDKLib.
What he's done here is he's removed a lot of the components that are in the ESP's SDK
and rewritten them and tightened them down and made them smaller and faster and better
than even the official SDK it seems and well, it's really cool what he's doing with this
and it allows us to go rip out all of this extra stuff.
All of these extra layers to get the chip to wake up send messages, be able to receive
a little bit and go back to sleep ridiculously fast.
The entire operation can happen in about 100ms as you can see on this graph.
So, making the chip boot up, load the program, send a message to the network and wait for
a response in case it needs to stay alive or do a buzzer.
This entire operation takes about 100ms.
About 20 or more times faster than the normal way of using an ESP8266.
And you can see here, it's actually a graph of power over time.
So, when the chip is booting up it's only using about 30ma down here.
Then when it's loading the program it's using a little more maybe about 40 ma.
Then, once the program's booted and it sends that packet, only is it using that 70mA of
power.
That thing that was using a huge amount of power before it's only doing that for about
20ms right here.
So this is a significantly lower amount of power.
In order to use this to send data to the internet we do have to do something a little bit unusual.
For this I am using regular off the shelf hardware, like this TPLink router right here.
The only difference instead of it running the normal TPLink software, it's running OpenWRT.
The most wonderful router software in the world.
It's like DD-WRT but much more customizable and easier to develop for.
One of the first things I needed to know is if it is possible for the router to both be
connected as an infrastructure and at the same time talk these raw packets, sending
and receiving to the ESP8266.
And the answer was yes.
Actually it was very easy.
For my program, all I had to do was make something that connected to wireless connection set
up a new dev.
Set up a new dev as a phy interface under monitor mode and I just print out a pcap header
this just a header for wireshark and any time the data comes in, I just literally print
the data out to standard out and see what happens.
And what happened on the other side, after I ran the program and piped it into wireshark
dash i dash dash k was well.
Well, I saw all the data coming down the pipe.
All of the random wireless packets flowing through the air I can now look at, including
the packets coming from the ESP8266.
Now, I've marked them with the world VOLTTE so they're easy for me to identify.
And inside these packets, they contain things like the frame number, and the voltage that's
on the 3.3v rail.
So, using this I'm going to be able to do something kind of similar to what Andreas
was doing.
Still using a regular old router just with a little bit of custom software.
Unfortunately for me, data.sparkfun.com looks like it's not going to be a thing anymore
so I won't be able to use the same tricks Andreas did.
So, I'm going to have to look elsewhere.
Instead what I decided to use was the form thing on Google Docs.
This allows you to make a form for people on the Internet to go fill out information
and submit it.
It also lets things that aren't people go fill out information and submit them, too.
So, I went and created this whole thing and copied the CURL line from it which is a line
you can just go execute and send data and ran that as a script on the TPLINK whenever
it saw one of the VOLTTE messages.
As you can see on the back of King Donut here, I have two coin cells, and these two coin
cells are in parallel with a 400uF capacitor.
And well, thank you King Donut for being part of this project.
And this is hooked up to the same old ESP.
And this time it's programed to go much more slowly.
This time it's programmed to update once every ten seconds I think it is.
And there's something kind of neat that you can see.
If you watch the results you see how it's 93 results.
As soon as the esp blinks you can see that number go up kind of quickly.
So let's wait and see when it blinks.
It's updating the fields in real time.
So as soon as the LED blinks.
::boop:: Now, 95 reports are in.
And on top of that, you can then go look at the public results in an and if you watch
this.
As soon as it blinks.
And.
Blink, another field gets inserted into the table.
There's a few other notes that I'd like to point out.
I did seem to have problems after a very very long time, if I didn't do any calibrations
at all, sometimes it seemed like the ESPs messages weren't getting to the TPLINK.
And I'm not sure why.
So, one of the things I'm trying to do is every 32 or 64, sorry, blinks I'm also doing
a full calibration.
So that does use more power but I'm curious if that helps.
All of the code is going to be on github.
One of the repositories is where I modified PVVX's meSDK.
And added the stuff so it could be super duper strip down and really fast.
The other one is the tplink-raw-wifi project.
So, this is where I have stuff like the data logger, the remote capture, stuff like that.
Turns out that this attempt at esp8266 with ESPNOW didn't really work out.
But yeah, I hope you guys like this, and I hope this works out.
And I hope to be able to report back soon with what my findings are.
Oh man this is cool.
Whenever this thing blinks it automatically adds the new line and it updates the graph
in google sheets.
We live in the future.
Truly we live in the future.