Author Topic: SBC68EC for analog/digital values sampling and transmission with http client  (Read 1797 times)


  • Newbie
  • *
  • Posts: 1
    • View Profile
The goal of this project was to :

- sample some analog values
- acquire data from french electric meter through serial interface
- be able to transmit them every minute with an http client (POST request) and then to save them in a mysql database with the help of php script.

- an additionnal function was to send every night (need of sntp client to get time information) an electric meter index (used to measure photovoltaic production) to the website with an md5 signature for authentication

My requirement was to reduce hardware development time as much as possible.
After some search on the internet I found the SBC68EC card with prototyping board and dedicated enclosure.

I bought two of them and start to write the software. I started with the SBC68 V3.06 software (V3.10 was not available at this time).

Main modification of the sofware are :

DNS client (net/dns.c) : fix of well known bugs of the dns client

HTTP client(net/httpclient.*) : created from tcputils.*. The http client is able to send a request defined in a file (saved in EEPROM filesystem).
The file is parsed to replace classical tags by their values. The http client is able to get response, line by line.

http.c : update of sendfile function to be able to use it with a tcp handle (and not an index on an arry of tcp handle) : by this way the function is usable with the http client to send parsed file.
tcp.c : fix of not well known bug in TCPGetArrayChr and TCPGetArray function (rxCount was not decreased during read operations)

Tick module : has been modified to handle tickSec on 32bits and to allow update of timer0L reloaded value to correct time drift.
Modification to avoid corrupted value of tick and tickSec in applicative loop when these multibyte values are modified by the timer interrupt at the wrong time.

SNTP module : get Microchip modified version on the internet. Add function from for time conversion. Personnal modifications to correct tick counter drift :
- internal time is set from sntp first response only.
- GMT time is then available by adding a tickSec difference to the original get timestamp

- Every hour an sntp query is send.
- a correction factor is calculated to update timer0L reload value. The goal is time convergence between internal time and external time

By this way the tick counters stay very accurate on very long period as internal timer are synchronised with sntp time.

A lot of commands and tags have been added in cmd.* file and httpexec.* file to save and display additionnal settings, to display some computed values eg :
- R00 is a second counter since last reset
- R03 is the unix timestamp

bdpv.* and websampling.* : good example (I hope) to drive httpclient and md5 modules.

MMI page have been updates. New page have been created with AJAX solution I find more readable than classical modtronix solution. Have a look to webs.htm and cgi, sntp.htm and cgi, bdpv.htm and cgi.

HTTP request definition can be found in httpreq.cgi and bdpvreq.cgi. For httpreq.cgi a trick has to be explained :
- as length of string returned by tags TI1 and TI2 is not known, a fake content-length header has to be defined. A value compatible with the biggest possible body has to be calculated.
- to avoid error if the body length is smaller than this value, some line of space are added at the end of the request body

Software informations in french are available here :
Additionnal MMI screenshot (sntp config page) are available at the end of :
V1.2.1 Software archive is downloadable here :

I apologize for my poor english and for my web site which is in french. Description given here are very short. Don't hesitate if you have some questions.

I hope some people may be interesting in implementing an http client in an SBC68EC for transmitting analog or digital measures to a website.