Uncategorized

ESP-01 and Ds18b20: watch the voltage!

I got one of those ESP-01s and a Ds18b20 (Dallas) sensor from Aliexpress for about 2 euros or so. The sellers say that they can get anywhere from 3.3V up to 12V. The ESP-01 works perfectly, but the temperature was always off by a number of degrees.

I use them with the incredible ESPHome on HomeAssistant. I’ll write more about them in another post.

ESP-01 with DS18B20. Cheap, but I still don’t trust it.

Given it has been working for months, I always thought that the thermometer was shit, and was looking at ways to offset it via software. But then I realized that the power supply of my breadboard was set to 5V.

I changed it to 3.3v, and this is what happened:

Temperature with 5V was constantly around 29ºC, but the place is always around 20. It’s closer to reality now.

As soon as I changed the power to 3.3V, temperature fell immediately 4ºC. The extra degree this morning seems to by my girlfriend closing the door of the lab (which makes it colder).

In conclusion: The ESP-01 will probably work with any voltage, but don’t trust temperature readings with it (the room is around 20º, so even with 3.3V, it’s still off).

Standard
Uncategorized

Time-Lapse Assembler on the Mac post-Mojave, 2019

Every time I had a sequence of images and I wanted to create a time-lapse video, I used an old tool called TimeLapse Assembler, version 1.5.3.

It worked fine, until Mojave.

Thing is, the developer abandoned the project around 2012, and Mac OS evolved and removed old frameworks. That means that it stopped working.

The author left a command-line version of it on GitHub, and it was clear why it stopped working: The libraries were all outdated. This nice soul fixed it, and here it is: Time Lapse Assembler For the Command Line.

To clone, it’s the usual:

git clone https://github.com/wadetregaskis/cocoa-tlassemble.git
cd cocoa-tlassemble
make

Usage:

cocoa-tlasseble/tlassemble --sort name *.png outputFile.mov --codec "JPEG"

For some weird reason, the author sorts the files per date, so you have to use the “–sort name” setting if you have renders from a render farm, for example.

Standard
Uncategorized

ESP-01 with Thermometers/Voltage regulators: Fix for “Failed to read from DHT sensor!”

Adafruit’s library is Broken.

Use it, but replace DHT.cpp with this one: https://raw.githubusercontent.com/adams13x13/DHT-sensor-library/761f4f4fb94c01afc283d0ffbfbfdeed5bb18a44/DHT.cpp

With that, I’m able to use this code to read from my devices:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DHT.h>
#define DHTTYPE DHT11
#define DHTPIN  2
// Replace with your network details
const char* ssid     = "Mywifi";
const char* password = "mypassword";

ESP8266WebServer server(80);
 
// Initialize DHT sensor 
// NOTE: For working with a faster than ATmega328p 16 MHz Arduino chip, like an ESP8266,
// you need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// This is for the ESP8266 processor on ESP-01 
DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266
 
float humidity, temp;  // Values read from sensor
String webString="";     // String to display
unsigned long previousMillis = 0;        // will store last temp was read
const long interval = 2000;              // interval at which to read sensor
 
 
void setup(void)
{
  Serial.begin(115200);  // Serial connection from ESP-01 via 3.3v console cable
  dht.begin();           // initialize temperature sensor

  // Connect to WiFi network
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("\n\r \n\rWorking to connect");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("DHT Weather Reading Server");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", [](){  
    gettemperature();       // read sensor
    webString="Temperature: "+String((int)temp)+" C Humidity: "+String((int)humidity)+"%" ;   
    server.send(200, "text/plain", webString); 
  });
  
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void)
{
  server.handleClient();
} 

void gettemperature() {
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis >= interval) {
    // save the last time you read the sensor 
    previousMillis = currentMillis;   

    // Reading temperature for humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
    humidity = dht.readHumidity();          // Read humidity (percent)
    temp = dht.readTemperature(false);     // Read temperature as CELSIUS
    // Check if any reads failed and exit early (to try again).
    if (isnan(humidity) || isnan(temp)) {
      Serial.println("Failed to read from DHT sensor!");
      return;
    }
  }
}

After that, I was able to run it in both my ESP-01 with DHT11, as shown here (running from 5v from the breadboard):

Problem is, those thermometers are terribly incorrect! My lab is around 22 degrees. What both sensors show?

So, yeah, that’s it for those things. I will search for something better.

Standard
Uncategorized

Syncthing, Raspberry Pi and SD cards’ life.

I have been using the great Syncthing for my backups, after I finally gave up on Resilio Sync. Basically because the memory consumption of it was unbearable on the Raspberry Pi which I use as the backup server together with an external hard drive.

It works just as well – if not better, its WAY lighter on resources, and it’s open source.

Those synchronization services have a problem, though. They keep many files for indexing their data. Millions of them.

And those files are stored at your home directory.

Which is on the SD card.

Got it already? If no, I will tell you. This will kill your SD card in no time. So, to solve it, move your .config/syncthing to the external hard disk, and do a symlink from the original location.

Something like

mv ~/.config/syncthing /media/externalDisk/
ln -s /media/externalDisk/syncthing ~/.config/syncthing

The same applies for Swap space. Raspberry PIs don’t usually have a separate partition, so they use by default the software dphys-swapfile which maps swap to a file, instead.

Given you are using a LOT of ram with SyncThing, your machine will swap. So, move it to the external hard drive as well just edit the

/etc/dphys-swapfile

and use a file on the external disk as well. It will make your SD card live WAY longer.

Standard
Uncategorized

ESP-01 without soldering

I’ve had one of those for quite some time, but never bothered to do anything with it, as all guides on the internet mentioned some jumper soldering to even start sending code to it.

IMG_0080.JPG

Recently, I stumbled over some serial controllers made only for this board: I bought it on AliExpress, for less than one euro: link ESP01-Programmer-Adapter-UART-GPIO0-ESP-01-Adaptaterr-ESP8266-USB-to-ESP8266-Serial-Wireless-Wifi-Developent.jpg

Thing is, you still need some soldering in order to make this run. What are they thinking?

Instead of that, I just forced some cable between the ESP-01 and this usb thing. Link this:

IMG_7841.JPG

Turns out it works!IMG_0584.JPG

Now, to make those super cheap DHT-11 temperature sensors with voltage regulator work with this, is another story….

But let’s be honest, it’s the cutest IoT/web server ever 🙂

IMG_2014.JPGIMG_7088.JPG

Standard
Uncategorized

NodeMCU ESP8266 v3 (Lolin) working!

I have been trying to make my cheap ESP8266 work for a while. There are multiple issues with them, including garbage output, wrong clock settings, the thing being oblivious to wifi and so on.

Turns out that removing and reinstalling ESP8266, and full update on Arduino and its libraries, and using those settings below, seem to do the trick:

Screen Shot 2018-02-25 at 23.31.34.png

Here is one of my boards, on a base, happily running a web server:

IMG_4365.JPG

PS: Those things accept anything from USB up to 24v. Great for car/motorbike projects!

Standard
Uncategorized

Files on ESP32 Micropython and how to scan networks on power up

Turns out it’s way easier than I expected. The ESP32 has a tiny filesystem which can be used to have files on. And, even better, there’s a “boot.py” file which is always executed after a power on or waking up from deep sleep. You just use the normal python file interface as you do on any code.

And this is valid even for writing the boot.py!

So, if you want to scan the wifi networks around at every boot, just plug your ESP32 onto your arduino IDE, and paste this, line by line, at the serial monitor:

f=open('boot.py','w')
f.write("print('************* Welcome to Strube ESP32 *************')\n")
f.write("import network\n")
f.write("station = network.WLAN(network.STA_IF)\n")
f.write('station.active(True)\n')
f.write("n=station.scan()\n")
f.write("print('Wifi networks around:')\n")
f.write("for i in n:\n")
f.write(" print(i[0])\n")
f.write("\n")
f.close()

This will create (or erase) a boot.py file (think of it as the AUTOEXEC.BAT from MS-DOS, or the AUTORUN.INI from windows), start the network module and scan for available Wi-Fi access points.

It shows something like this (I removed the names of the networks which don’t happen to be my coffee machine):Screen Shot 2018-02-14 at 17.54.00.png

Don’t know why the “ENOENT” error at the end yet.

Standard