A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By gerardwr
#2465
gerardwr wrote:Some suggestions for expanding:
- Store the CSTARTLOG in flash, so that it starts automatically after a reboot.
- report the #seconds with fractions or report #milliseconds too. I have a LED on my DumpPowemeter that flashes for a number of milliseconds related to current power consumption, and rounding to #seconds gives a major error.

@Borstenhorst
I really like your work on the Smartmeter example.

It’s an excellent basis for a more general „sensor” module using the ESP8266.

Just dreaming aloud here, without considering the technical feasibility.

Expand the CSTARTLOG with:
1. A parameter (#period) that periodically reports the measurement. If #period=0 then it is reported „as-is”, if #period=60, the most recent #(milli)seconds that GPIO2 was LOW is reported to the server every 60 seconds.
2. the possibility to select GPIO0 (or other GPIO# for modules like ESP-03) for logging purposes too.
3. the possibility to switch between several GPIO2 logging modes, f.i:
= Mode 1 to send URL to server when GPIO2 changes level, and report the level.
= Mode 2 to send URL to server containing analog value on GPIO2. (I have no idea if GPIO2 could be assigned as analog pin).
= Mode 3 to ........

The CSTARTLOG could then look something like this:
Code: Select allAT+CSTARTLOG="<protocol>","<URL>”,”<#mode>,<#period>,<#gpio>,<#port>
User avatar
By Borstenhorst
#2611
alonewolfx2 wrote:Its starting with at command over serial. I need to start on the user main.c and i dont want to any other mcu or serial adapter. I need connect website and send data and deepsleep mode for 1 minute. I figure deepsleep and wake up. But i cant send data in usermain.c without any other serial adapter or mcu's


I know this issue and I tried find a way to store the configuration into the flash and besides that, not blowing up the whole AT-Firmware as I would write to address where I don't know what else is there. I have not figured out how to do that to be honest or lets have it that way: I wait for guys to come up with an awesome SDK which is including another awesome API for duing stuff like that, instead of spending too much time on this topic.

On the other hand it should be simple to start hard coded configurations.
It might be possible you can't do that form the main directly as the rest of the system is not loaded at that point but this can easily be solved with a timer or a callback.

If you just want to pass the configuration to the function I would do it the nasty way (and keeping it simple) by saving the AT command parameters into a string and passing it to the AT+CSTARTLOG

@gerardwr
Great Ideas!
I'm currently in a situation where I hardly can find time to continue working on this project. But hey! The sources are online and your ideas (besides the flash) should be easy implementable.
If you go for the improvement of the timebase you can also try to implement interrupts, there is now a bit more documentation available than when I wrote that code.
I would love to see the result!
User avatar
By gerardwr
#2656
Borstenhorst wrote:I'm currently in a situation where I hardly can find time to continue working on this project. But hey! The sources are online and your ideas (besides the flash) should be easy implementable.
If you go for the improvement of the timebase you can also try to implement interrupts, there is now a bit more documentation available than when I wrote that code.
I would love to see the result!


I had a quick look at your sources. I saw that a timer is set to 1000 milliseconds, and at every tick the level of the GPIO is checked. When at some time the level is HIGH, the number of timer-ticks that the GPIO level was LOW is reported by the GET URL. Hence the second resolution.

So changing the time setting from 1000msec to 1msec would result is a granularity of 1 msec instead of 1sec. Seems to be a simple change. Not sure if the performance of the ESP could handle such as change.

I saw also in the source comments like "change this to GPIO interrupt later". This would probably a better approach, but much more complicated.

In the meantime (1 week timeframe re. ESP development is HUGE) I had a look at the Lua interpreter firmware that is published in another topic on this forum.
In the documentation a 10 line Lua script is published, implementing a pulse width counter on interrupt basis with a msec? accuracy. Sure some lines have to be added to send the counter value to a web server, but an additional 10 lines will do that.

Coding such a script language would lead (me) to success waaaaaaay faster than changing the rather complex C structure of the AT-SDK, I intend to follow this route for now, as it enables fast prototyping. It also enable a fast implementation to he million other things I would like to do with my ESP's.

A lot of your work has gone into the www part, that remains valuable.

So if you see a result from ME, it's probably a Lua script solution, inspired by your Native Smartmeter/datalogger. Thanks for the inspiration!