Wyze cam firmware mods

… I was looking for cheap ip cameras which allow modding the firmware. After some googling, I found Wyze cams. These cute littles ones range around $25 to $35, work great (few hours of usage so far) and arrive from Amz in a day. Modding took me some hours, but there were lessons which I am sharing below.

Screenshot from 2018-12-04 03-08-15

Mod Installation

Followed the steps at git repo with my additions in bold:  https://github.com/openipcamera/openipc-firmware

  1. Download this git repository.
  2. Copy the contents of firmware_mod/v2/ to the root of your sdcard.
  3. Set up Wifi in the SD card config folder wpa_supplicant.conf (rename .dist file. See example below)
  4. Power off your camera, insert the SD card
  5. Hold the setup button, plug in your USB cable, keep holding the setup button for 3-6 seconds
  6. Once the light is solid blue, release the button and wait for 3-4 minutes. The camera will reboot and change light status during this time.
  7. The camera will appear on your network with a mac address similar to this: C8:02:8F:10:03:FA
  8. To access the web interface, visit the camera’s IP address in your browser (http://xxx.xxx.xxx.xxx). Username: dafang Password: ismart12
  9. RTSP stream (when enabled), rtsp://xxx.xxx.xxx.xxx:8554/unicast (works for vlc).

My Notes:

  • In step 3 above, rename the file by removing .dist extension.
  • In wpa_supplicant, for WPA2, use wpa-psk (see example below)
  • Once the above procedure is complete, the regular reboot of camera will load the open firmware from microsd (without us holding the setup button)
  • For tinycam android app, use generic brand with protocol=rtsp over tcp, and request url in above format. Same url also works for vlc without authentication.
  • default ssh creds: root/ismart12
  • Location of configs via ssh is /system/sdcard/config
  • Configs changes to above location via ssh are persisted across reboots
  • Vendor assigned mac address of camera doesn’t match the mac after new firmware (?)
# Uncomment to connect to Hidden SSIDs
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40

Issues & Fixes

Issue #1: Camera not reading sd card.
I placed a FAT formatted 1 GB microsd card with above git software, but camera went directly to ‘ready to connect’ without even starting software from sd card.

The Fix: I installed the wyze app. And connected the cam using usual steps. (As always, do not update firmware when asked by vendor, if you aren’t certain of mods availability for new version).
Then I formatted the sd card (after putting in camera) using the option in that app.After that, followed same instructions as above git using that formatted sd card.

Lesson: SD card that I formatted in linux didn’t work. When formatted by camera itself, it worked fine.

Issue #2: The web server was not accessible.
All the steps worked till Step #8. The camera was appearing in router dhcp’d list, but there was no ping or nmap response.

The issue was my network. My pc (from which i was accessing web server) was on a different network (home network) versus the camera (guest network).

I blocked camera traffic via its mac, and placed it on home network, after which web server and rest of services were accessible.

hints: https://github.com/openipcamera/openipc-firmware/issues/49


I found later that rtsp server was not auto starting on boot. The fix was to ssh into the camera and add an executable (perm: 755) file in /system/sdcard/config/autostart with command to start rtsp server:

/system/sdcard/controlscripts/rtsp-h264 start


From Zero to Smart Switch

.. I wanted to switch on a light bulb, with my phone, without giving up my data, in a scalable way (managed and financial).

Material List:

  • Raspberry Pi with raspbian running (any existing one will work)
  • Sonoff switch (approx $6; check out 3-pack from Amazon)
  • Optional: regular wire with plug on one end (e.g. wire cut from old lamp)

Summarized Steps:

  1. Install tasmota on sonoff via raspberry pi
  2. Install sonoff in the wall
  3. Use Pi as MQTT server

What is Sonoff?

My definitions:

  • Sonoff = { esp8266 + relay + power supply } in a small package.
  • esp8266 = { arduino + wifi }
  • ardunio = { microcontroller to run your code }
  • relay = { use tiny voltage to control (switch on/off) higher voltage connection }

Can you build something like sonoff yourself? Yes, but compact packaging with psu and pricing makes it too compelling to not build yourself. But one should be aware that all arduino knowledge is still valid and one can write their own sketch (firmware).

Sonoff comes with default firmware from Itead, and was locked to eWelink app – something that I didn’t wanted to use. At a minimum, I wanted a standard control protocol (like mqtt) to be exposed that does not traverses across continents. Tasmota is the favorite one on the Internet that fits my needs.

Replacing the Firmware:

There are few ways to replace default sonoff firmware with tasmota:

  1. OTA (over-the-air) <== I started with this
  2. Wired via USB-to-TTL cable
  3. Wired via Raspberry Pi and few wires. <== this is what I ended up doing

The OTA method ‘may work‘ as long as you don’t upgrade sonoff to latest Itead firmware (2.6 at the time of this post). Originally, sonoff from amazon came with 1.5.x version. Here are the steps for OTA: mirko/SonOTA,  but for me the ‘FinalStage’ ssid never showed up, and the sonoff kept doing 2-blinks (meaning, cannot connect to web server). This itead link explains the blink combinations.

If you are in same boat, the Wired option is not complicated (just 4 wires). Here is a good link: arendst/Sonoff-Tasmota, and the original and more detailed one: Michel Deslierres. This one also recommends taking backup of older firmware.

My Firmware Notes:

  • Raspberry pi should have serial interface enabled using raspi-config. Reboot pi, otherwise, esptool will give you ‘Connecting ….._____…..’ and timeout.
  • If the nano edit of cmdline.txt gets struct, simply open the file using nano and edit it.
  • Instead of soldering, I was ‘impatient + lazy’ and connected the pins via alligator clips. After a few hiccups, it worked. Bad connection errors were: ‘A fatal error occurred: Corrupt data, expected 0x1000 bytes but received 0xfff bytes.’. BTW in the picture below, the white A/C supply is disconnected.Screenshot from 2018-11-26 07-57-49
  • Complete all the steps. At the final step (password), you have to be quick and exact. I think I tried (restarting terminal) 3-4 times, because of typos, delays.

The switch is now up and can be installed in the wall. You should test it with a A/C wire before installation at the final location in the wall. I chose to put it near the bulb. You can find the IP address of the switch from your router. Use it to simply type it in the browser: http://<ip address of the switch>. Hear the relay click on pressing the toggle button.

Screenshot from 2018-11-26 08-41-56

Control via MQTT:

Why MQTT? Lightweight, Controlling multiple switches without going to each web url, more elegant programmatic control than curl requests and more. Here is my proposed architecture

Screenshot from 2018-11-26 08-52-15

Quick 15 seconds of  mqtt: There are topics and there are messages. You setup server (-h for host). Start listening on some topic (-t) . Someone sends a message (-m).

Server: (raspberry pi)
sudo apt-get install mosquitto mosquitto-clients
sudo systemctl start mosquitto

Subscriber: (from another other host)
mosquitto_sub -h <ip address of pi> -t test

Publisher: (from yet another other host)
mosquitto_pub -h <ip address of pi> -t test -m msg

MQTT Setup:

Setup raspberry pi as the server. After that give the ip address of pi to: Sonoff Configuration -> Configure MQTT.

Now from any device in the network, you can issue commands to the switch.

mosquitto_pub -h <ip address of pi> -t cmnd/switch1/POWER -m ON

mosquitto_pub -h <ip address of pi> -t cmnd/switch1/POWER -m OFF

Replace switch1 with your own friendly name (Sonoff -> Configuration -> Configure Other)

And that’s it!

Hadoop Ecosystem Contributors (Q3 2018)

Data as of 2018-09-28, based on count of committers or pmc.

Hadoop contributions 2018-09-28 06-58-54

WebHDFS on Hadoop 3 with Java 9

Unable to browse WebHDFS on Hadoop 3 running on JDK 9.

On Browsing the file system:

Failed to retrieve data from /webhdfs/v1/?op=LISTSTATUS: Server Error

In the namenode logs:

java.lang.NoClassDefFoundError: javax/activation/DataSource

On namenode, in hadoop-env.sh, add:

export HADOOP_OPTS="--add-modules java.activation"


An alternate to slack on Pi 3 (Rocket.Chat)

Rocket.Chat is an open source alternative to slack, and I have been thinking about using it at home. The ubuntu install was painless and very easy, but it didn’t make sense to keep a box up all the time – at least at home. So the best home deployment platform was an sbc (Pi 3).

Installation on pi was ‘mostly’ easy (followed official link) except for the persistence layer – mongodb. Rocket.chat required a newer version of mongodb, and the github page offered a cloud-based alternative for mongodb hosting. To me the whole solution being on-premise (actually whole solution on-pi) was major convincing point, so I avoided that route. After few searches, I located a post by Andy Felong, where he had already compiled binaries for arm architecture (Pi 2 and 3 – Jessie) of mongodb 3.0.9. Although the steps he had listed to deploy mongodb using his binaries were straightforward, I still scripted it; in case if I had to reinstall things again (link to script on github).

After mongodb was installed, the Rocket.chat server started smoothly. My beta testers (my kids) were ready to jump on it as soon as I created their user accounts. So much that at one point, when a file upload was a bit slow; I saw my son clicking the button multiple times – and suddenly all of them got a yellow header in chat interface due to server unavailability. I went back to terminal and there was a stack-trace waiting. This was the right time to graduate the interactive start into supervisor-based run.

The more interesting part was integration via webhooks. Rocket.chat supports writing webhooks wrappers in javascript e.g. it was very easy to pull live images from webcam.

Here is the launch.sh:

export PORT=3000 
export ROOT_URL= 
export MONGO_URL=mongodb:// 
export ADMIN_USER=admin
export ADMIN_PASS=*****
export ADMIN_EMAIL=admin@somedomain
/home/pi/meteor/dev_bundle/bin/node /home/pi/rocketchat/bundle/main.js

And the supervisor’s run-as-svc.sh:

echo "Note: Start this script as sudo"
if [ -f "$svcconf" ]; then
  echo "supervisor config already exists"
  echo "creating supervisor config - first time only"
cat > /etc/supervisor/conf.d/rocketchat.conf <<EOF
echo "Starting process"
supervisorctl reread
supervisorctl update
supervisorctl restart rocketchat

Finally, the only disappointment was android cordova-based app. It kept on showing media less pages (no images, or css loaded) in the webview. I think it could be due to some baked expectations of SSL within the app.

Overall, a fun little project with great potential with webhooks. Some thoughts for webhooks: web cluster/pool member status, build status notifications, current server load, or how Chicago downtown looks like at this exact minute.