ESP8266 and Wiznet 5500 raw support

This commit is contained in:
2018-03-10 02:07:05 +03:00
parent 45cbd8b4a0
commit 7fb2cf4fcc
8 changed files with 483 additions and 254 deletions

View File

@@ -1,5 +1,5 @@
# LightHub
is Flexible, Arduino-Mega based SmartHome controller
is Flexible, Arduino-Mega/Arduino DUE/ESP8266 based SmartHome controller
It allow to connect together:
@@ -16,7 +16,7 @@ Scalability is virtually unlimited: Setup so many controllers you needed in most
Prease refer our Wiki for insructions.
Just started preparation to porting firmware to AVR based Arduino DUE and ESP8266/ESP32
Finished portation of proejct to Arduino DUE and ESP8266 (ESP32 not tested)
Compiled image has been added to compiled/ folder
use
@@ -39,7 +39,7 @@ For patched libraries, appropriate GitHub repo URL provided:
* DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
* FastLED
* Wire (standard)
* Artnet
* Artnet https://github.com/anklimov/Artnet.git
* DmxSimple https://github.com/anklimov/DmxSimple (for AVR) or https://github.com/anklimov/ESP-Dmx (for ESP) or https://github.com/anklimov/DmxDue (for DUE)
* HTTPClient (for AVR) https://github.com/anklimov/HTTPClient or https://github.com/arduino-libraries/ArduinoHttpClient for other platforms
* aJson https://github.com/anklimov/aJson
@@ -51,8 +51,7 @@ For patched libraries, appropriate GitHub repo URL provided:
* Ethernet https://github.com/anklimov/Ethernet
* SPI (standard)
Portation from AVR Mega 2560 to SAM3X8E (Arduino DUE) is done since v 0.96
Next step ESP portation
Portation from AVR Mega 2560 to SAM3X8E (Arduino DUE) done since v 0.96
#Platforms specific details:
@@ -64,5 +63,14 @@ SAM3X8E:
*both, DMX-in and DMX-out are hardware USART based. Use USART1 (pins 18 and 19) for DMX-out and DMX-in
ESP:
*Wifi instead Ether not implemented yet
*DMX-IN not possible to deploy
*DMX-OUT on USART1 TX
*DMX-IN - not possible to deploy in ESP8266
*Modbus - disabled. Might be configured in future on USART0 instead CLI/DEBUG
since v. 0.97:
There is first attempt to use Wiznet 5500 (still not stable enough)
Need to use compiler directive -D Wiz5500 and https://github.com/anklimov/Ethernet2 library
First attempt to use platformio toolchain for compiling (work not completed yet)

36
lib/readme.txt Normal file
View File

@@ -0,0 +1,36 @@
This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.
The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".
For example, see how can be organized `Foo` and `Bar` libraries:
|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c
Then in `src/main.c` you should use:
#include <Foo.h>
#include <Bar.h>
// rest H/C/CPP code
PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.
More information about PlatformIO Library Dependency Finder
- http://docs.platformio.org/page/librarymanager/ldf.html

View File

@@ -180,7 +180,7 @@ for (int i=1; i<17; i++) {Serial.print(dmxin.read(i));Serial.print(";");}
}
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data, IPAddress remoteIP)
{
#ifdef _dmxout
for (int i = 0 ; i < length && i<MAX_CHANNELS ; i++)

54
lighthub/esp.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include "options.h"
#ifdef __ESP__
#include "esp.h"
ESP8266WiFiMulti wifiMulti;
WiFiClient ethClient;
char mqtt_password[16];
//default custom static IP
//char static_ip[16] = "10.0.1.56";
//char static_gw[16] = "10.0.1.1";
//char static_sn[16] = "255.255.255.0";
//flag for saving data
bool shouldSaveConfig = false;
//callback notifying us of the need to save config
void saveConfigCallback () {
Serial.println("Should save config");
shouldSaveConfig = true;
}
void espSetup () {
Serial.println("Setting up Wifi");
shouldSaveConfig = true;
//WiFiManager
WiFiManagerParameter custom_mqtt_password("", "mqtt password", mqtt_password, 16);
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;
wifiManager.setSaveConfigCallback(saveConfigCallback);
wifiManager.addParameter(&custom_mqtt_password);
wifiManager.setMinimumSignalQuality();
if (!wifiManager.autoConnect()) {
Serial.println("failed to connect and hit timeout");
delay(3000);
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(5000);
}
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
//read updated parameters
strcpy(mqtt_password, custom_mqtt_password.getValue());
}
#endif

24
lighthub/esp.h Normal file
View File

@@ -0,0 +1,24 @@
#include <ESP8266WiFi.h>
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <ESP8266WiFiMulti.h>
extern ESP8266WiFiMulti wifiMulti;
extern WiFiClient ethClient;
//WiFiManager wifiManager;
//define your default values here, if there are different values in config.json, they are overwritten.
//length should be max size + 1
extern char mqtt_password[16];
//default custom static IP
//char static_ip[16] = "10.0.1.56";
//char static_gw[16] = "10.0.1.1";
//char static_sn[16] = "255.255.255.0";
//flag for saving data
extern bool shouldSaveConfig;
void espSetup ();

View File

@@ -106,7 +106,13 @@ Config webserver
#else
#ifdef Wiz5500
#include <Ethernet2.h>
#else
#include <Ethernet.h>
#endif
EthernetClient ethClient;
#endif
@@ -250,7 +256,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
} //no1wire
}
#ifndef __ESP__
void printIPAddress()
{
Serial.print(F("My IP address: "));
@@ -259,9 +265,10 @@ void printIPAddress()
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(F("."));
}
Serial.println();
}
#endif
void printMACAddress()
{
Serial.print(F("My mac address: "));
@@ -397,7 +404,9 @@ break;
// do notghing with net
}
{
#ifndef __ESP__
wdt_dis();
if (lanStatus>0)
switch (Ethernet.maintain())
@@ -437,7 +446,7 @@ if (lanStatus>0)
}
wdt_en();
#endif
}
return lanStatus;
@@ -873,7 +882,7 @@ void postTransmission()
void setup() {
cmdInit(115200);
Serial.println(F("\nLazyhome.ru LightHub controller v0.96"));
Serial.println(F("\nLazyhome.ru LightHub controller v0.97"));
cmdAdd("help", _handleHelp);
cmdAdd("save", _saveConfig);
@@ -1187,6 +1196,3 @@ if (items)
} // if items
} //proc

View File

@@ -14,17 +14,18 @@ src_dir = lighthub
platform = atmelavr
board = megaatmega2560
framework = arduino
build_flags =
-D Wiz5500
lib_deps =
https://github.com/livello/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxSimple
https://github.com/anklimov/HTTPClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet
126
https://github.com/PaulStoffregen/SPI.git
https://github.com/knolleary/pubsubclient.git
https://github.com/natcl/Artnet.git
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxSimple
https://github.com/anklimov/HTTPClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet2
https://github.com/PaulStoffregen/SPI.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git

100
platformio.txt Normal file
View File

@@ -0,0 +1,100 @@
; PlatformIO Project Configuration File (for copy and paste)
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[platformio]
src_dir = lighthub
[env:due]
platform = atmelsam
framework = arduino
board = due
build_flags =
-D Wiz5500
ib_deps =
https://github.com/sebnil/DueFlashStorage
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxDue
https://github.com/arduino-libraries/ArduinoHttpClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/Ethernet2
https://github.com/PaulStoffregen/SPI.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git
[env:megaatmega2560-5500]
platform = atmelavr
board = megaatmega2560
framework = arduino
build_flags = -D Wiz5500
lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxSimple
https://github.com/anklimov/HTTPClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet2
https://github.com/PaulStoffregen/SPI.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git
[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxSimple
https://github.com/anklimov/HTTPClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/anklimov/Ethernet
https://github.com/PaulStoffregen/SPI.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git
[env:due]
platform = atmelsam
framework = arduino
board = due
ib_deps =
https://github.com/sebnil/DueFlashStorage
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxDue
https://github.com/arduino-libraries/ArduinoHttpClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/Ethernet
https://github.com/PaulStoffregen/SPI.git
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git
[env:espressif8266]
platform= espressif8266
framework = arduino
board = nodemcuv2
ib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/ESP-Dmx
https://github.com/arduino-libraries/ArduinoHttpClient
https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster
https://github.com/anklimov/DMXSerial
https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git