ESP8266

Artnet, WS2812 and ESP8266 (Arduino IDE)

Posted on Updated on

From my previous post I have updated the program to be compiled from Arduino IDE.

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <Adafruit_NeoPixel.h>

#define WSout 5                                     // Pin D1
#define ARTNET_PORT 6454

#define PIXELCOUNT 100


byte hData[318];

const int number_of_channels=300; //512 for 512 channels

const char* ssid     = "";
const char* password = "";

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(PIXELCOUNT,WSout,NEO_GRB+NEO_KHZ800);

WiFiUDP udp;


IPAddress local_ip(192, 168, 1, 190);
IPAddress gateway_ip(192, 168, 1, 1);
IPAddress subnet_ip(255, 255, 255, 0);

void setup() {
  
  Serial.begin(115200);
  delay(100);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  WiFi.config(local_ip, gateway_ip, subnet_ip);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  udp.begin(ARTNET_PORT); // Open ArtNet port

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());


pixels.begin();

  for(byte i=0;i<PIXELCOUNT;i++){
    pixels.setPixelColor(i, Color(0,0,0));
  }
  pixels.show();
  
}

void loop() {
  if (udp.parsePacket()) {
    udp.read(hData, 318);
   // pixels.setPixelColor(0, Color(hData[19], hData[20],hData[21]));
  for ( int n=0; n<100; n++){   
     pixels.setPixelColor(n, Color(hData[(n * 3) + 19], hData[(n *3)+20],hData[(n *3)+21]));
    }
   pixels.show();
  }
}

uint32_t Color(byte r, byte g, byte b){
  uint32_t c;
  c = r;
  c <<=8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}

The WS2812 data line is connected to D1 from the NODEMCU board.

NODEMCU_D1

Config of the Arduino IDE

config_arduino_1

It looks like it work better than the code in Lua.

This comes from a similar program I did few years ago to run 10 matrices of 10 x 10 pixels. I was using WS2801 led stripes, arduino UNO and ethernet shield.

Everything still runs smooth untill now.

Some photos of matrix installed and the controller running JINX.

Advertisements

Artnet, WS2812 and ESP8266 (Lua)

Posted on Updated on

From my previous post on Artnet ESP8266, I had some feedback about some trouble. I decided to make it again but with the WS2812.

2017-05-21 11_49_58-NodeMCU custom builds

Once compiled you will receive an email with a link to download the firmware.

Upload the firmware with Nodemcu flasher and change the path to point to the custom firmware

2017-05-21 16_01_25-Open2017-05-21 16_01_56-nodemcu

With Esplorer, upload this program:

2017-05-21 16_10_41-ESPlorer v0.2.0-rc5 by 4refr0nt

wifi.setmode(wifi.STATION)
wifi.sta.config("*****","*****",1)
tmr.delay(5000000)   -- wait 1,000,000 us = 1 second
print(wifi.sta.getip())
print("Running")
gpio.mode(4, gpio.OUTPUT)
ws2812.init()
tmr.delay(1000000)
ws2812.write(string.char(0,0,0):rep(100))
s=net.createServer(net.UDP)
s:on("receive",function(s,c) ws2812.write(string.sub (c, 19, 318)) end)
s:listen(6454)

I am driving a Matrix (10*10) of 100 pixels.

In the UDP loop, I am extracting the 300 bytes (19 to 318) corresponding to each RGB values of each pixels; 3 * 100. Bytes 1 to 18 are the Artnet header.

The led stripe is connected to PIN D4 of my NODEMCU Board

nodemcu_D4

Forgot to mention that a fast wifi router is needed.

Enjoy…

ESP8266+18650

Posted on Updated on

The other day I came across this nice stuff; A board with an ESP8266, a battery 18650 holder and a charging circuit. Really cool stuff.

I bought a couple of them.

I flashed it using the nice firmware ESPURNA. The firmware is a great piece of code. Thanks for that. Gràcies Xose.

An interesting thing about ESPURNA is about the way the web UI was compiled.

To install the libraries necessary to compile the code, please follow the wiki from the site. It is very explicit.

A screenshot of the Arduino IDE config folr the board

IDE_setting

It has been running a couple of days now and everything is smooth. Need to test the sleep mode because the battery is not lasting long, about 15 hours. Charging cycles are OK too.

Nice board.

Virtual Serial Port over IP

Posted on

If you like to connect from your Windows environment to your newly ESP8266 ESP-Link, you may use the very good software from Tibbo to create a virtual serial port.

http://tibbo.com/support/downloads/tdst.html

Download the version corresponding to your system (x32 or x64).

Install the package.

Open Tibbo VSP Manager and Add a port

step_0

Set the properties of the port as following to creat a TCP connection to the ESP8266 flashed with ESP-Link. The IP at the bottom is the IP address of the ESP82266!

Once done, a virtual port will be created in the COM section of the Device Manager.

For testing, use the serial console of Arduino IDE. (One of my temperature logger is sending data through the ESP8266).

From the console of the ESP-Link

step_7

 

I don’t know if it is possible to use the serial port to program an arduino that way but I know that the control lines could be changed from the setting. Let’s see, I will give it a try later.

Enjoy.

 

Steps to flash ESP-Link to ESP8266 4 Mbyte (ESP12)

Posted on Updated on

Just few words about flashing ESP-Link on ESP8266 (I posted first working on the ESP01 but gave it up. It bugs a lot. I use now a 4 Mbyte version.)

Yesterday I was looking (bit lazy) to make an ESP8266 TCP / Serial bridge in order to remote control one of my Nextion screen with Node-red (development and testing only).

While browsing I found out ESP-Link. Very nice tool. (Pity, I found that too late)

So, in few steps, to flash it you need to:

  • Download ESP-Link flasher software

http://www.espressif.com/en/support/download/other-tools?keys=&field_type_tid%5B%5D=14

  • Download firmware

https://github.com/jeelabs/esp-link/releases/tag/v2.2.3

  • Get the hardware info of the ESP

To do so, connect to the ESP the tool ESP flash download tool and press start.

step_1

Once the button start is pressed, you will get the hardware details in the Detected Info window.

step_2

Use the info for setting the right flash size and also the right address for flashing.

  • Use this setting for flashing:

step_3

  • Connect to the ESP8266 AP
  • In your browser go to: 192.168.4.1
  • You are good to go for more setting from the webpage

If you like to erase the flah, use the method of Patrik @

Completely format or erase ESP8266 flash memory

ESP8266: Artnet receiver

Posted on Updated on

The other I was playing with a matrix of led. The matrix is made of a stripe of WS2801.

So, here is what I have done.

  1. I flash a new lua based firmware in the ESP8266 using Marcel’s NodeMCU custom build cloud service.
    Add WS2801 and / or WS2812 modules
  2. Wait and download the compiled firmware
  3. Flash it using the tool ESPtool
  4. I use ESPlorer to program the ESP
    1. Create a new ini.lua
    2. Copy the following lines of code.
      This is for a matrix 10×10 “snakelines”

      wifi.setmode(wifi.STATION)
      wifi.sta.config("******","******",1)
      tmr.delay(5000000)   -- wait 1,000,000 us = 1 second
      
      ws2801.init(0, 2)
      tmr.delay(1000000)
      
      ws2801.write(string.char(0,0,0):rep(100))
      
      s=net.createServer(net.UDP)
      s:on("receive",function(s,c) ws2801.write(string.sub (c, 19, 318)) end)
      s:listen(6454)
  5. Use Jinx or Glediator (I prefer Jinx) to drive the matrix and send the Artnet commands to the ESP8266

It works very well.
The code is simple and works well. I haven’t tried on large matrix but I think for larger matrix a fast wifi connection would be needed.