Thursday, 29 December 2022

Christmas weather station?

 Well, a parcel from Ben arrived today, and apparently it is the components for a weather station. 

[11:30, 29/12/2022] Ben Grant-Jones: Yes, looks about right. Does it have an Arduino, a screen and various sensors?

[11:36, 29/12/2022] Ben Grant-Jones: I think it's called an Ideaspark weather station kit.

https://www.hackster.io/alien-energy-3/what-do-i-build-next-a-simple-weather-station-cdc4ed

The wiring schematic is here

[11:37, 29/12/2022] Peter Merchant: Looks like 4 sensors, a computer board of some type, and other bits.

The computer in it is a LoLin NodeMcu v3.  Onwards and upwards!

Let's look at that Hackster  site and see how I'll put it together and what power supply is required. I think that that power converter that Ben sent in a previous parcel will be required here for 3.3V.

30/12/22 Bits included are:

A very small screen. I can't find a part number on it.   4 pins for power and serial comms. 

GY-30 Light intensity sensor. Also  5 pins for power and serial comms + ADO?

GY-68 180BMP Atmospheric pressure sensor.  4 pins for power and serial comms. 

11DHT (Possibly) Temperature humidity sensor. 

I think it is this: 

https://www.amazon.co.uk/Temperature-Humidity-Atmosphetic-BH1750FVI-YellowBlue/dp/B07GPBBY7F/ref=sr_1_13?crid=VBUYHQW3XS8M&keywords=ideaspark&qid=1672402295&sprefix=ideaspark%2Caps%2C81&sr=8-13

Have downloaded demo software from Blog site.

A BAD NIGHT:  Arduino IDE seems to have disappeared from my computer. I installed  Arduino IDE version 2.01, and it does not have my board, and the Boards manager is not present.   Time to give up for tonight.

Removed Arduino IDE 2.0? and installed 1.8.19

Installed the following libraries to get the hardware and bits to get it to compile

ttps://mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json, https://arduino.esp8266.com/stable/package_esp8266com_index.json, 

https://github.com/vlast3k/Arduino-libraries/blob/master/SSD1306/SSD1306Wire.h

It gets over this now, and has an error with:   ESP8266_Weather_Station/src/ESPHTTPClient.h:4:10: fatal error: HTTPClient.h: No such file or directory

Other people who have done it:

https://randomnerdtutorials.com/cloud-weather-station-esp32-esp8266/

https://github.com/ThingPulse/esp8266-weather-station   [ this might be the one used here]

https://thingspeak.com

23/1/2023 - Working through the compilation: 

fatal error: SSD1306Wire.h: No such file or directory

this is installed: SSD1306 oled driver library for the Wemos Mini OLED shield (64x48)

but is it the right one? 

Installed:  / esp8266-oled-ssd1306

That got a lot further, but now:

WeatherStationDemo:70:21: error: 'D3' was not declared in this scope

   70 | const int SDA_PIN = D3;

and same with D4. 

Changed from Generic 8266 Module to Lolin Wemos D1,R2 and Mini

That Verified!  Let's program it. 

25/1/2023

Now all wired up, and connected to Wifi, displaying forecasts. 

There is an error in the wiring diagram in the Hackster weather station that I am building.  The Ground and VCC of the display go to the wrong pins. 

Next step is to look at software and see how to get to read the sensors.

NOTE: when I load software into the Arduino IDE, change board to ESP8266 -> Lolin (Wemos ) D1, R2, and Mini

#define TZ              0       // (utc+) TZ in hours
*** Bad one - later TZ is multiplied!
TZ=0 gave UTC+1, 
TZ= 1 gave UTC+2

But have I not set up something correctly. 

String OPEN_WEATHER_MAP_LOCATION = "London,GB";

STEP 5  Register OpenWeathermap, thingspeak new account

https://github.com/ThingPulse/esp8266-weather-station/blob/master/examples/WeatherStationDemo/WeatherStationDemo.ino
gives a link to Thingspeak to get the API code for the weatherstation. 
I have put this in the .ino file. 
Now I believe i need to select the weathermap location. 

const char *host = "api.thingspeak.com";                  //IP address of the thingspeak server

const char *api_key ="c4b7d4b2331c0baac3e329358384e378";                  //Your own thingspeak api_key

This one is wrong I think

and this one is correct:

String OPEN_WEATHER_MAP_APP_ID = "c4b7d4b2331c0baac3e329358384e378";

String OPEN_WEATHER_MAP_LOCATION = "2633863";

Time is now wrong by +2 hours and all data is set to 0.

and the next few days info is all thurs,thurs,thurs, so something has gone wrong with the timing.

from here: https://nothans.com/thingspeak-documentation/api

In order to update a channel, you need to know your Write API Key. If your Write API Key gets compromised you can generate a new key.
Follow these steps to get your Write API Key:

  • Select Channels
  • Select the Channel to update
  • Select Manage API Keys      
There is also a read API Key. I don't know which I need here. 

On the thingspeak channel display I can see that all sensors are displaying some changes. Success!

--------------- --------------- ------------ -

26/1/23  Got time right. Had to set TZ to -1.

Have to use 'write' API key to write things to thingSpeak. 


This is what serial monitor shows:

temp:18    humi:62

light: 165

Pressure = 103155 Pascal

temp:18    humi:62

light: 165

Pressure = 103153 Pascal

temp:18    humi:62

light: 165

Pressure = 103154 Pascal

temp:18    humi:62

light: 165

Pressure = 103145 Pascal

SO why doesn't it display!

27/1/23 Changed Channel view from private to public, but it still doesn't display, so it doesn't read the stuff. 

29/1/23  Current state.
There are three things, 
1] It gets and displays the time     --Yes
2] It reads the sensors and writes them to Thingspeak  --Yes
3] It reads the weather forecast from OpenWeathermap and displays it on the two screens.   --No. 

Some other sites that may give some help:

https://randomnerdtutorials.com/esp32-http-get-open-weather-map-thingspeak-arduino/

https://forum.arduino.cc/t/arduino-uno-esp8266-01-and-openweathermap-org-for-weather-monitoring/458438
 -- waste of time.

https://www.instructables.com/Esp8266-Weather-Data-Parser-Openweathermap/
 - This uses a totally different TFT screen and would be far too much work to convert. 

Tried it with the Thingspeak API read key for Openweathermap - didn't work.


30/1/2023  End of. Going to leave this project for a bit. 







Tuesday, 8 November 2022

New Project - Reprogramming/fixing a Smart WiFi Socket

Following on from discussions on Twitter, I think that I should do this. 

It uses Tasmota devices and MQTT  to show what is using power when. 

An excellent writeup  by @Brunty in his blog:  https://brunty.me/post/energy-monitoring-2022-edition/

To start I need some Tasmota devices. They ain't cheap.

Can I convert my TUYA Smart devices to Tasmota. @Andysc says I can. Will I still be able to control them to turn TV ON & off at specified times automatically? 

There is Tasmotrol, but it is written by a person (Yvonne Joh) who I don't know anything about. Does it feed stuff back to China like TUYA Smart? 

I will need a home Server running 24/7, and at the moment all I have is a few spare black tower PC's. 

Can I find a small unit that plugs into a mains socket and will support some storage?   Looked for 'PC in a plug' and found some references to things like Sheevaplug, but they all seem to have ceased. 

I'll have to get a Raspberry Pi to fit into my dead Humax box when they are available. 

Suggestion that I should look at Balena_io and MING. I might have to learn some more programming if I went that route. 

Keep thinking about it.  Have discovered that Enphase uses MQTT, but I think that this is in old versions of the software. Good if it still does.  How can I test it?

21 Nov. 22

Going to flash one of my TUYA smartplugs with Tasmotrol.

The device is a https://expo.tuya.com/product/627497  model J2-SU-E16

Following https://www.superhouse.tv/44-over-the-air-tasmota-conversion-with-tuya-convert/

Setting up Rasberry Pi (10) 

It has flashed, Not sure if it was successful. 

When plugged in, no light. But Wifi Network tasmota_02AC61-3169

MAC address 12:e9:be:e7:26:65


Have left a comment on the superhouse web page.

26 Nov 22. Have taken it apart and discovered that the chip in it is a common Popular one ESP-12S, and have unsoldered it from the unit. Have ordered a USB to TTL serial interface board so that I can program it. 

Best link that I have found is: 

https://templates.blakadder.com/ESP-12.html

This one has videos of programming them. 

https://www.hackster.io/brian-lough/3-simple-ways-of-programming-an-esp8266-12x-module-c514ee


29 March 2023 looking at this to make it simple:

https://www.youtube.com/watch?v=8yxEgYvoHY0

I have now found tasmotizer:

-- peterm@peterm-MBB-34204H:~$ find -name "*tasmotizer*"
-- ./.local/bin/__pycache__/tasmotizer.cpython-38.pyc
-- ./.local/bin/__pycache__/tasmotizer.cpython-310.pyc
-- ./.local/bin/tasmotizer.py
-- ./.local/lib/python3.10/site-packages/__pycache__/tasmotizer_esptool.cpython-310.pyc
-- ./.local/lib/python3.10/site-packages/__pycache__/tasmotizer.cpython-310.pyc
-- ./.local/lib/python3.10/site-packages/tasmotizer-1.2.1.dist-info
-- ./.local/lib/python3.10/site-packages/tasmotizer_esptool.py
-- ./.local/lib/python3.10/site-packages/tasmotizer.py
-- ./.local/lib/python3.8/site-packages/__pycache__/tasmotizer.cpython-38.pyc
-- ./.local/lib/python3.8/site-packages/__pycache__/tasmotizer_esptool.cpython-38.pyc
-- ./.local/lib/python3.8/site-packages/tasmotizer-1.2.1.dist-info
-- ./.local/lib/python3.8/site-packages/tasmotizer_esptool.py
-- ./.local/lib/python3.8/site-packages/tasmotizer.py

But it won't run because it is missing some bits

following instructions to install tasmota from web i/f But it cannot find USB serial port. 

https://tasmota.github.io/docs/Getting-Started/#needed-software

Web:  https://tasmota.github.io/install/

Have downloaded basic Tasmota from http://ota.tasmota.com/tasmota/release/

This nearly works with the TTL-USB dongle that Ben gave me. It didn't react with Mine. 

Here is another story about step-by-step programming a device with Tasmota.

https://blog.horner.tj/emporia-smart-plugs-tasmota/

This tells how to set Bootloader mode on GPIO15 (pin10)

https://docs.espressif.com/projects/esptool/en/latest/esp8266/advanced-topics/boot-mode-selection.html

7 April 2023.

So I need GPIO-15 Pulled low to enable flashing. This is the pin next to GND. 

SUCCESS!

Following a hint online:

sudo apt-get install python3-pyqt5.qtserialport

and now this works:

 python3 ./.local/lib/python3.8/site-packages/tasmotizer.py
and brings up tasmotizer. 

But I need to find the config file. 

On TAsmotizer, just click the little box for the section that you want to config, so I did and added the Wifi credentials, and then 'saved' this config, which sent it to the device.   Fing found it, but the tasmotizer tablet app didn't. I think I need to set up a tasmotizer web server for this, which probably means using a Raspberry Pi. 

Correction: Fing did not find it. and searching for a WIFI connection to it found nothing either. 

Wrote to Horner re my problems

Hi, as suggested in your blog on this, I am asking for the benefit of your experience. I have an unbranded Smart Switch with TUYA software. It is very similar to the Lombex unit: https://templates.blakadder.com/lombex_U11.html.   I have removed the ESP12 microprocessor and connected it to my Kubuntu computer, and have been able to flash it using 

https://tasmota.github.io/install/   It was necessary to connect both GPIO-15 and GPIO-0 to 
ground to get it to flash. and then have started Tasmotrol to configure it, which seems to work. 
I then tried to send the generic module configuration, and that transferred. The problem is that the 
device never appears in my wireless network  - testing with fing on my tablet. 

Not sure what other info I can give you to help. Attached is a picture of the connection.
 
The ESP-12S came out of the slot on the main board of the unit. 

Any thoughts appreciated,
------------------- ---------------- ------------
another similar plug:
https://templates.blakadder.com/silentnight_485418G.html 

with a comment that  New Tuya devices have replaced their Wi-Fi module with one incompatible 

with Tasmota!!!

10/4/23 Likely conclusion: None of the Tasmota buolds loaded  have had wireless working, so my 

supposition is that Tuya are using an ESP-12 in this device that uses the Realtek wifi drivers rather 

than their original ones. 

I am going to test this hypothesis using these three links:

1]  https://www.instructables.com/Getting-Started-with-the-ESP8266-ESP-12

2]  https://www.instructables.com/ESP-12E-ESP8266-With-Arduino-Uno-Getting-Connected/

3]  https://circuitjournal.com/programming-esp8266-over-wifi

This one 3] is about working with these variants ESP-12E / ESP-12F / NodeMCU so I'll leave it for now. 

2] is about an 8266 E and builds on 1] so I'll start there. 

It has a warning about not using the 3V3 from the USB-TTL adapter as it doesn't supply enough power. 

I cannot get the Arduino IDE serial monitor to  show anything. 

Trying to get an Arduino program working for the ESP8266, and I just get this error:

"module 'time' has no attribute 'time_ns'" in /tools/mkbuildoptglobals.py  and can't find a cure. Something to 

do with the version of Python perhaps. 


16/4/23  Interesting teardown of a couple of smart plugs:

https://www.hackster.io/news/teardown-of-a-smart-plug-or-two-6462bd2f275b

The TCP-Smart plug that I have  contains this:

https://developer.tuya.com/en/docs/iot/wb2s-module-datasheet?id=K9ghecl7kc479

and looks like this. 











2023-05-19

Discovered a new article about programming an ESP-12 with Tasmota

https://www.elektroda.com/rtvforum/topic3816654.html

It implies that the  WB2S in the TCP switch has to be replaced with an ESP-12 device.











 





Wednesday, 14 September 2022

Old Humax 9150T as Raspberry Pi PVR

 Humax PVR is dead. NVRAM has failed so it won't store configuration or recording schedule.   What can I do with it? 

It has hard disk, and Power supply and plenty of room inside. 

https://magpi.raspberrypi.com/articles/pivr-pi-pvr    It has been done before. 

This calls for a powered USB hub. 

I'll need USB-SATA connection. 

How much power can I get from the Humax PSU?   Need to suss out the pins. 

If I used a R-Pi 3B+  it would have wireless. 

Humax PSU has 8 wires running from it,  4 are +12 and 4 are Ground. Each set of four is all connected together on the PCB. 

I have bought a dual 5V converter module so that I can give 5 volts to the R-Pi and 5 volts to the SATA disc.      23/9/2022 - This has arrived as has a USB to SATA converter.  So now the hard disk can be connected to the driving computer. 

16/8/2024  Pi 3B+ has arrived. Shall I get my TV Tuner back from Ben, or buy a new one, or a TV HAT? 

I have printed a Raspberry Pi case to mount the Pi in the case. 








Monday, 28 February 2022

Build my own electric bike?

 Not a Swytch bike, but build it myself.

I have aslways wanted to learn to weld, and this might be the project that fixes that idea.

Things that I will need, I think:

 - Motor  for the front wheel, with appropriate spoke holes for the wheels that I have. 

- Spokes

- switch and controller, and sensor to decide when to use it.

- Battery and charging mechanism.

- and what else? 

What is available in the first? 

https://www.cyclingnews.com/features/best-e-bike-motors/