German wordclock with ESP8266 ESP-12e - Upload Problems
Posted: Thu Mar 03, 2016 3:42 am
Hello,
i have an ESP-12e (Geekcreit ESP12E) with Arduino IDE 1.6.5 + ESP8266 2.1.0-rc1 + ESP Data Sketch Uploader.
This ESP have a CH340 USB/Serial Interface Chipset an is 5V compatible.
I try to upload a sketch from "Ulrich Radig" with an Wordclock Software (Time Sync over NTP) and control of 114x WS2812B LEDs
The ESP should present a WLAN with SSID "Uhr" and Password "12345678".
I have a data Folder with 3x index html files and the Clock Sketch.
I try to Upload the sketch + ESP Data Sketch Uploader.
The upload will be confirmed successfull.
But i don´t see this WLAN?
Here´s a short cut of this sketch:
i have an ESP-12e (Geekcreit ESP12E) with Arduino IDE 1.6.5 + ESP8266 2.1.0-rc1 + ESP Data Sketch Uploader.
This ESP have a CH340 USB/Serial Interface Chipset an is 5V compatible.
I try to upload a sketch from "Ulrich Radig" with an Wordclock Software (Time Sync over NTP) and control of 114x WS2812B LEDs
The ESP should present a WLAN with SSID "Uhr" and Password "12345678".
I have a data Folder with 3x index html files and the Clock Sketch.
I try to Upload the sketch + ESP Data Sketch Uploader.
The upload will be confirmed successfull.
But i don´t see this WLAN?
Here´s a short cut of this sketch:
Code: Select all
/ - 26.09.15 WLAN konfigurieren und speichern / WLAN-AP starten
// - 26.09.15 ESP.reset();
// - 27.09.15 Hintergrundfarbe einstellen
// - 27.09.15 Startwerte in Eeprom speichern
// - 27.09.15 Helligkeits-Regler ??
// - 05.10.15 json Modul
// - 12.10.15 Uhrzeit lokal einstellen
// - 30.10.15 Laufschrift
// - HTML-Seiten speichern im FS ???
// - RTC Modul
// - Zeitverlauf Farben konfigurierbar
// - Zeitzone und Sommer/Winter-Zeit / ermitteln
// Sommer-Zeit: Letzter Sonntag März um 2 Uhr
// Winter-Zeit: Letzter Sonntag Oktober um 3 Uhr
// - Zeitserver eintragen
// - Server-IP eintragen
// - Erreichbare WLANs vorblenden / Scannen
// - Überblenden
// - Tretis
#include <Arduino.h>
#include <ws2812_i2s.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <WebSocketsServer.h>
#include <Hash.h>
#include <Time.h>
#include "FS.h"
#include <EEPROM.h>
#include "EEPROMAnything.h"
#include <ArduinoJson.h>
#include "font.h"
#define DEBUG
#define USE_SERIAL Serial
#define UHR_110
//#define UHR_169
#ifdef UHR_110
#define NUM_PIXELS 110
#define NUM_SMATRIX 110
#define ROWS_MATRIX 10
#endif
#ifdef UHR_169
#define NUM_PIXELS 169
#define NUM_SMATRIX 121
#define ROWS_MATRIX 11
#endif
#define ESIST 0
#define VOR 1
#define NACH 2
#define UHR 3
#define FUENF 4
#define ZEHN 5
#define VIERTEL 6
#define ZWANZIG 7
#define HALB 8
#define EINS 9
#define H_EIN 10
#define H_ZWEI 11
#define H_DREI 12
#define H_VIER 13
#define H_FUENF 14
#define H_SECHS 15
#define H_SIEBEN 16
#define H_ACHT 17
#define H_NEUN 18
#define H_ZEHN 19
#define H_ELF 20
#define H_ZWOELF 21
static WS2812 ledstrip;
static Pixel_t pixels[NUM_PIXELS];
const char *ssid_ap = "Uhr";
const char *password_ap = "12345678";
// uh
unsigned char wlan_station = false;
unsigned int _sekunde = 0;
unsigned int _minute = 0;
unsigned int _stunde = 0;
unsigned int last_minute = 100;
//unsigned int tag = 1;
//unsigned int monat = 1;
//unsigned int jahr = 2000;
unsigned long unix_time = 0;
unsigned int counter1 = 0;
unsigned int counter2 = 0;
unsigned int counter3 = 0;;
struct GLOBAL {
unsigned char status_flag;
unsigned char uhr_flag;
int r;
int g;
int b;
unsigned char prog1;
unsigned char prog2;
unsigned char prog3;
unsigned char prog4;
unsigned char par1;
unsigned char par2;
unsigned char par3;
unsigned char par4;
unsigned char delay;
unsigned char bg_r;
unsigned char bg_g;
unsigned char bg_b;
unsigned char rr;
unsigned char gg;
unsigned char bb;
int zeitzone;
};
GLOBAL G = { };
unsigned long previousMillis = 0;
const long interval = 1000;
const int timeZone = 1; // Central European Time
uint32_t uhrzeit;
char ls_txt[50];
#include "uhr_func.h"
#include "ntp_func.h"
//-- WebSocketserver
WebSocketsServer webSocket = WebSocketsServer(80);
// A UDP instance to let us send and receive packets over UDP
//WiFiUDP udp;
char str[200];
struct config_t
{
int sernr;
char ssid[25];
char passwd[25];
int r;
int g;
int b;
int bg_r;
int bg_g;
int bg_b;
int zeitzone;
} S;
//------------------------------------------------------------------------------
void eeprom_write()
{
EEPROM_writeAnything( 0, S );
EEPROM.commit();
}
//------------------------------------------------------------------------------
void eeprom_read()
{
EEPROM_readAnything( 0, S );
#ifdef DEBUG
USE_SERIAL.println(S.sernr);
USE_SERIAL.println(S.ssid);
USE_SERIAL.println(S.passwd);
USE_SERIAL.println(S.r);
USE_SERIAL.println(S.g);
USE_SERIAL.println(S.b);
USE_SERIAL.println(S.bg_r);
USE_SERIAL.println(S.bg_g);
USE_SERIAL.println(S.bg_b);
USE_SERIAL.println(S.zeitzone);
#endif
delay(100);
}
//------------------------------------------------------------------------------
void setup()
{
G.status_flag = 0;
G.uhr_flag = 0;
G.r = 0;
G.g = 0;
G.b = 0;
G.prog1 = 0;
G.prog2 = 0;
G.prog3 = 0;
G.prog4 = 0;
G.par1 = 0;
G.par2 = 0;
G.par3 = 0;
G.par4 = 0;
G.delay = 0;
G.bg_r = 0;
G.bg_g = 0;
G.bg_b = 0;
G.rr = 0;
G.gg = 0;
G.bb = 0;
G.zeitzone = 0;
// Start Serielle Schnittstelle
#ifdef DEBUG
USE_SERIAL.begin(38400);
USE_SERIAL.println("");
#endif
delay(100);
ledstrip.init(NUM_PIXELS);
bool result = SPIFFS.begin();
EEPROM.begin(512);
eeprom_read();
#ifdef DEBUG
USE_SERIAL.printf("S.sernr:%u S.r:%u S.g:%u S.b:%u \n", S.sernr, S.r, S.g, S.b);
#endif
if (S.sernr !=105){
for( int i = 0; i < 512; i++ ){ EEPROM.write(i,i); }
EEPROM.commit();
S.sernr = 105;
strcpy(S.ssid, "WLAN");
strcpy(S.passwd, "12345678");
S.r = 0;
S.g = 0;
S.b = 80;
S.bg_r = 0;
S.bg_g = 0;
S.bg_b = 0;
S.zeitzone = 1;
eeprom_write();
}
G.r = S.r;
G.g = S.g;
G.b = S.b;
G.bg_r = S.bg_r;
G.bg_g = S.bg_g;
G.bg_b = S.bg_b;
G.zeitzone = S.zeitzone;
// Scan Network
WiFi.disconnect();
WiFi.mode(WIFI_STA);
int n = WiFi.scanNetworks();
#ifdef DEBUG
USE_SERIAL.println("scan done");
#endif
if (n == 0)
{
#ifdef DEBUG
USE_SERIAL.println("no networks found");
#endif
delay(10);
}
else
{
#ifdef DEBUG
USE_SERIAL.print(n);
USE_SERIAL.println(" networks found");
#endif
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
#ifdef DEBUG
USE_SERIAL.print(i + 1);
USE_SERIAL.print(": ");
USE_SERIAL.print(WiFi.SSID(i));
USE_SERIAL.print(" (");
USE_SERIAL.print(WiFi.RSSI(i));
USE_SERIAL.print(")");
USE_SERIAL.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
#endif
delay(10);
}
}
test_led();
led_clear();
ledstrip.show(pixels);
// Start WiFi
WiFiStart();
if (wlan_station == true) {
#ifdef DEBUG
USE_SERIAL.println("Starting UDP");
#endif
udp.begin(localPort);
#ifdef DEBUG
USE_SERIAL.print("Local port: ");
USE_SERIAL.println(udp.localPort());
#endif
}
// Zeitanfrage beim NTP-Server
if (wlan_station == true) {
set_ntp_zeit();
// Zeit setzen
setTime(unix_time);
}
// Test Uhranzeige
//--test_uhr(800);
// Anzeige Uhrzeit
//--strip.clear();
/*
for ( unsigned int i = 10; i > 0; i--) {
char d1[5];
char d2[5];
sprintf(d1,"%d",(int)(i / 10));
sprintf(d2,"%d",(int)(i % 10));
zahlen(d1[0], d2[0]);
delay(500);
}
led_clear();
strcpy( ls_txt, "HELLO WORLD " );
laufschrift(100,100,100, 100);
laufschrift(100,100,100, 100);
*/
set_bg_color();
set_bg();
_sekunde = second();
_minute = minute();
_stunde = hour();
set_uhrzeit();
ledstrip.show(pixels);
webSocket.begin();
webSocket.onEvent(webSocketEvent);
#ifdef DEBUG
USE_SERIAL.println ( "Websockest started" );
#endif
}
//------------------------------------------------------------------------------
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
counter1++;
//counter2++;
counter3++;
}
webSocket.loop();
// Test, obf WLAN connected
if (WiFi.status() != WL_CONNECTED)
{
// WiFiStart();
}
// NTP Zeit neu holen
if (counter3 > 14400) {
if (wlan_station == true) {
set_ntp_zeit();
if (unix_time > 0) {
setTime(unix_time);
#ifdef DEBUG
USE_SERIAL.println(unix_time);
USE_SERIAL.print(hour());
USE_SERIAL.print(":");
USE_SERIAL.print(minute());
USE_SERIAL.print(":");
USE_SERIAL.print(second());
USE_SERIAL.print(" - ");
USE_SERIAL.print(day());
USE_SERIAL.print(".");
USE_SERIAL.print(month());
USE_SERIAL.print(".");
USE_SERIAL.println(year());
#endif
}
}
counter3 = 0;
}
if (G.uhr_flag == 1) {
set_bg_color();
set_bg();
set_zeit(0);
ledstrip.show(pixels);
G.uhr_flag = 0;
}
if (counter1 > 1) {
// switch (counter2) {
// case 0: wischen(100, 0, 0, 80); break;
// case 1: schieben(80, 0); break;
// case 2: laufen(20, 0); break;
// }
// counter2++;
// if (counter2 > 3){ counter2=0; }
_sekunde = second();
_minute = minute();
_stunde = hour();
if (last_minute != _minute){
#ifdef DEBUG
USE_SERIAL.printf("Zeit: %d:%d:%d / %d\n", _stunde, _minute, _sekunde, last_minute);
#endif
led_clear();
set_bg_color();
set_bg();
set_uhrzeit();
ledstrip.show(pixels);
last_minute = _minute;
}
counter1 = 0;
}
if (G.uhr_flag == 30) { // Uhrzeit setzen
_sekunde = second();
_minute = minute();
_stunde = hour();
set_bg_color();
set_bg();
set_uhrzeit();
ledstrip.show(pixels);
G.uhr_flag = 0;
// Zeitzone auch hier speichern ???
}
if (G.uhr_flag == 20) { // Startwerte speichern
#ifdef DEBUG
USE_SERIAL.println("Startwerte gespeichert");
USE_SERIAL.println(G.r);
USE_SERIAL.println(G.g);
USE_SERIAL.println(G.b);
#endif
S.r = G.r;
S.g = G.g;
S.b = G.b;
S.bg_r = G.bg_r;
S.bg_g = G.bg_g;
S.bg_b = G.bg_b;
eeprom_write();
delay(1000);
G.uhr_flag = 0;
}
if (G.uhr_flag == 98) { // Zeitzone speichern und
S.zeitzone = G.zeitzone;
eeprom_write();
delay(500);
G.uhr_flag = 0;
if (wlan_station == true) {
set_ntp_zeit();
if (unix_time > 0) {
setTime(unix_time);
#ifdef DEBUG
USE_SERIAL.println(unix_time);
USE_SERIAL.print(hour());
USE_SERIAL.print(":");
USE_SERIAL.print(minute());
USE_SERIAL.print(":");
USE_SERIAL.print(second());
USE_SERIAL.print(" - ");
USE_SERIAL.print(day());
USE_SERIAL.print(".");
USE_SERIAL.print(month());
USE_SERIAL.print(".");
USE_SERIAL.println(year());
#endif
}
_sekunde = second();
_minute = minute();
_stunde = hour();
#ifdef DEBUG
USE_SERIAL.printf("Zeit: %d:%d:%d / %d\n", _stunde, _minute, _sekunde, last_minute);
#endif
led_clear();
set_bg_color();
set_bg();
set_uhrzeit();
ledstrip.show(pixels);
}
G.uhr_flag = 0;
}
if (G.uhr_flag == 99) { // WLAN-Daten speichern und neu starten
eeprom_write();
delay(1000);
ESP.reset();
ESP.restart();
while (1){delay(1);};
G.uhr_flag = 0;
}
}
//------------------------------------------------------------------------------
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
#ifdef DEBUG
USE_SERIAL.printf("Client-Nr.: [%u] WStype: %u payload: %s\n", num, type, payload);
#endif
switch(type) {
case WStype_DISCONNECTED:
{
#ifdef DEBUG
USE_SERIAL.printf("[%u] Disconnected!\n", num);
#endif
break;
}
case WStype_CONNECTED:
{
IPAddress ip = webSocket.remoteIP(num);
#ifdef DEBUG
USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
#endif
break;
}
case WStype_TEXT:
{
#ifdef DEBUG
USE_SERIAL.printf("[%u] get Text: %s\n", lenght, payload);
#endif
for (int k=0;k<lenght;k++){
str[k] = payload[k]; //does this "copy" is buggy code?
}
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(str);
if (!root.success()) {
Serial.println("parseObject() failed");
//return;
break;
}
const char* command = root["command"];
if (strcmp (command,"1") == 0) {
G.uhr_flag = 1;
G.r=atoi(root["r"]);
G.g=atoi(root["g"]);
G.b=atoi(root["b"]);
}
if (strcmp (command,"2") == 0) {
G.uhr_flag = 1;
G.bg_r=atoi(root["bg_r"]);
G.bg_g=atoi(root["bg_g"]);
G.bg_b=atoi(root["bg_b"]);
}
if (strcmp (command,"2") == 0) {
G.uhr_flag = 1;
G.bg_r=atoi(root["bg_r"]);
G.bg_g=atoi(root["bg_g"]);
G.bg_b=atoi(root["bg_b"]);
}
if (strcmp (command,"20") == 0) {
G.uhr_flag = 20;
}
if (strcmp (command,"30") == 0) {
G.uhr_flag = 30;
uint32_t tt=atoi(root["time"]);
G.zeitzone=atoi(root["offset"]);
#ifdef DEBUG
USE_SERIAL.printf("Time: %d\n", tt );
#endif
setTime(tt);
}
if (strcmp (command,"98") == 0) {
G.uhr_flag = 98;
G.zeitzone=atoi(root["zeitzone"]);
#ifdef DEBUG
USE_SERIAL.printf("Time: %d\n", G.zeitzone );
#endif
}
if (strcmp (command,"99") == 0) {
G.uhr_flag = 99;
const char* s = root["ssid"];
const char* p = root["passwd"];
strcpy(S.ssid, s);
strcpy(S.passwd, p);
}
#ifdef DEBUG
USE_SERIAL.println(command);
#endif
//--echo data back to browser
//webSocket.sendTXT(num, payload, lenght);
//-send data to all connected clients
//webSocket.broadcastTXT(payload, lenght);
break;
}
case WStype_BIN:
{
#ifdef DEBUG
USE_SERIAL.printf("[%u] get binary lenght: %u\n", num, lenght);
#endif
hexdump(payload, lenght);
//--echo data back to browser
//webSocket.sendBIN(num, payload, lenght);
break;
}
}
}
//------------------------------------------------------------------------------
void WiFiStart()
{
unsigned int count = 0;
// Connect to WiFi network
#ifdef DEBUG
USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.print("Connecting to ");
USE_SERIAL.println(S.ssid);
USE_SERIAL.println(S.passwd);
#endif
WiFi.disconnect();
// WLAN-Mode Station stetzen
WiFi.mode(WIFI_STA);
WiFi.begin((const char*)S.ssid, (const char*)S.passwd);
while (count < 25) {
if (WiFi.status() != WL_CONNECTED) {
count++;
delay(500);
#ifdef DEBUG
USE_SERIAL.print(".");
#endif
} else {
break;
}
}
if (WiFi.status() == WL_CONNECTED) {
#ifdef DEBUG
USE_SERIAL.println("");
USE_SERIAL.println("WiFi connected");
// Print the IP address
USE_SERIAL.println(WiFi.localIP());
#endif
wlan_station = true;
} else {
#ifdef DEBUG
USE_SERIAL.println("");
USE_SERIAL.println("Setup WiFi Access-Point");
#endif
WiFi.disconnect();
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid_ap, password_ap);
delay(500);
IPAddress myIP = WiFi.softAPIP();
#ifdef DEBUG
USE_SERIAL.print("AP IP address: ");
USE_SERIAL.println(myIP);
#endif
wlan_station = false;
}
}
//------------------------------------------------------------------------------
/*
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
*/
//------------------------------------------------------------------------------
/*
void rainbow(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256; j++) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i + j) & 255));
}
strip.show();
delay(wait);
}
}
*/
//------------------------------------------------------------------------------
/*
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
*/
//------------------------------------------------------------------------------
/*
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j = 0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}
*/
//------------------------------------------------------------------------------
/*
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}
*/
//------------------------------------------------------------------------------
/*
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
*/
//------------------------------------------------------------------------------
/*
void DigitalClockDisplay() {
int h, m, s;
s = millis() / 1000;
m = s / 60;
h = s / 3600;
s = s - m * 60;
m = m - h * 60;
USE_SERIAL.print(h);
printDigits(m);
printDigits(s);
USE_SERIAL.println();
}
void printDigits(int digits) {
USE_SERIAL.print(":");
if (digits < 10)
USE_SERIAL.print('0');
USE_SERIAL.print(digits);
}
*/
//------------------------------------------------------------------------------