tymto sa pridavam k bastlicom v Arduine a s radostou vam ponukam svoje minidielko. Umožňuje zobrazovať v smartphone aktualne napatie baterii a zaznamenane minimalne a maximalne napatie v ramci dna, aj s uvedenim casu. Cas sa natiahne z NTP servera pri starte arduina. Realizacia celeho riesenia vyzera v telefone takto:

Samotna Android appka, ktora zabezpecuje zobrazenie HTML arduinom generovanej stranky v automaticky refreshovanom widgete sa da stiahnut tu:
https://play.google.com/store/apps/deta ... S53ZzAxIl0.
Tu je arduino kod:
- Kód: Vybrat vše
#include <Time.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
//TCP/IP konfiguracia
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2,177);
EthernetServer server(80);
EthernetClient client02;
// NTP konfiguracia
IPAddress timeServer(132, 163, 4, 101); // time-a.timefreq.bldrdoc.gov
const int timeZone = 2;
EthernetUDP Udp;
unsigned int localPort = 8888; // local port to listen for UDP packets
const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message
byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets
// Premenne widgetu
float maximum = 0;
int max_hod;
int max_min;
float minimum = 100;
int min_hod;
int min_min;
int den = 0;
float napatie;
// Setup
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
Udp.begin(localPort);
setSyncProvider(getNtpTime);
}
//A rob dokola
void loop() {
EthernetClient client = server.available();
if (client) {
// Serial.println("Novy klient");
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head>");
client.println("</head>");
client.println("<body style='background-color:#FFEBD7;'>");
int scitavane = 0;
for (int a = 1; a<=20; a++) {
int sensorReading = analogRead(3);
delay(100);
scitavane = scitavane + sensorReading;
}
client.print("<div><span style='font:100px arial,sans-serif;'>");
float napatie = (float)(round((((float)scitavane/(float)20)) * (float)0.03193172626682720 * (float)10)/(float)10);
client.println((float)napatie,1);
client.println("V</span>");
// Ak je aktualne cislo mensie ako minimum, updatni minimum
if ((float)napatie < (float)minimum) {
minimum = (float)napatie;
min_hod = (int)hour();
min_min = (int)minute();
Serial.print("Preniesol som nacitane: ");
Serial.println(min_min);
}
// Ak je aktualne cislo vacsie ako maximum, updatni maximum
if ((float)napatie > (float)maximum) {
maximum = (float)napatie;
max_hod = (int)hour();
max_min = (int)minute();
}
client.print("<br>");
client.print("<span style='font:16px arial,sans-serif; width:200px;padding-left:10px;'>");
client.println("Min: <b>");
client.print(minimum,1); client.print("V</b> ");
client.print((min_hod));client.print(":");
if (min_min < 10) {client.print("0");}
client.print((min_min));
client.print("; ");
client.println("Max: <b>");
client.print(maximum,1);client.print("V</b> ");
client.print(max_hod);client.print(":");
if (max_min < 10) {client.print("0");}
client.print(max_min);
client.println("</span></div>");
// Ak sa zmenilo cislo dna, nuluj
if ((int)den != (int)day()) {
minimum = 100;
maximum = 0;
den = (int)day();
}
client.println("</body>");
client.println("</html>");
break;
}
if (c == '\n') {
currentLineIsBlank = true;
}
else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
// Dajme browseru trochu casu
delay(1);
client.stop();
// Serial.println("client disonnected");
}
}
time_t getNtpTime()
{
while (Udp.parsePacket() > 0) ; // discard any previously received packets
Serial.println("Transmit NTP Request");
sendNTPpacket(timeServer);
uint32_t beginWait = millis();
while (millis() - beginWait < 1500) {
int size = Udp.parsePacket();
if (size >= NTP_PACKET_SIZE) {
Serial.println("Receive NTP Response");
Udp.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer
unsigned long secsSince1900;
// convert four bytes starting at location 40 to a long integer
secsSince1900 = (unsigned long)packetBuffer[40] << 24;
secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
secsSince1900 |= (unsigned long)packetBuffer[43];
return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;
}
}
Serial.println("No NTP Response :-(");
return 0; // return 0 if unable to get the time
}
// send an NTP request to the time server at the given address
void sendNTPpacket(IPAddress &address)
{
// set all bytes in the buffer to 0
memset(packetBuffer, 0, NTP_PACKET_SIZE);
// Initialize values needed to form NTP request
// (see URL above for details on the packets)
packetBuffer[0] = 0b11100011; // LI, Version, Mode
packetBuffer[1] = 0; // Stratum, or type of clock
packetBuffer[2] = 6; // Polling Interval
packetBuffer[3] = 0xEC; // Peer Clock Precision
// 8 bytes of zero for Root Delay & Root Dispersion
packetBuffer[12] = 49;
packetBuffer[13] = 0x4E;
packetBuffer[14] = 49;
packetBuffer[15] = 52;
// all NTP fields have been given values, now
// you can send a packet requesting a timestamp:
Udp.beginPacket(address, 123); //NTP requests are to port 123
Udp.write(packetBuffer, NTP_PACKET_SIZE);
Udp.endPacket();
}
V kode je na prepocet hodnot z A/D prevodnika pouzita konstanta 0.03193172626682720, bude potrebne si ju upravit v zavislosti od konfiguracie vasho napatoveho delica. Napatie mi prepocitava bud presne na desatinu volta, pripadne o jednu desatinu volta viac (len preto, ze som nemal presny multimeter pri vypocte konstanty). S kodom si samozrejme robte, co len chcete, za pripadne skody samozrejme nerucim.

A treba mat samozrejme od internet providera verejnu IP a know-how, ako si ju preroutovat na IP arduina. Komu sa casto meni verejna IP, moze si zriadit ucet na no-ip.com a pristupovat k arduinu cez domenovy nazov, napriklad (nejakynazov.no-ip.info).
Este fotka nasho hi-tech satnika:
Zlava hore doprava dole:
Skatulka, v ktorej je skryte Arduino. Ma vetracie otvory, vobec sa neprehrieva. Hrubsi cierny kabel v sebe skryva napatovy delic;
PWM regulator;
Hasiaci pristroj;

Mechanicky prepinac siete;
Elektromer solarneho okruhu;
Zasuvka "silna" - vzdy je v nej prud z verejnej siete;
Zasuvka prepinana - bud prepnuta verejna siet, alebo solarna;
Napajanie arduina;
WiFi repeater - don je kablom pripojene Arduino.