MicroPython on ESP8266

January 31, 2017 by · Leave a Comment
Filed under: Blog 

This is an example post, extracted from my
OneNote Notebook with specifics on getting micropython working on
ESP8266.
Please excuse any typos below… there
are my notes after all, and I only am publishing them as an example of
what is possible with OneNote.

Micropython
on Esp8266 Tutorial
https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/index.html

http://micropython-on-wemos-d1-mini.readthedocs.io/en/latest/setup.html

Using
Wemos D1 with esp8266MOD
The
WROOM v2 (aka ESP-13, aka ESP8266MOD
From <https://esp8266hints.wordpress.com/tag/esp8266mod/>
With 4MB SPI flash
Using
wemos d1 pro
No
module, 16M SPI flash

Install / load / reinstall micropython on
the Wemos D1

Install the driver-

The wemos d1 uses a cheap
CH340 USB to UART

driver download:
https://www.wemos.cc/downloads/


<<CH341SER_win.zip>>
After
installing python on pc, need to install python and then use the
ESPtool to install or reflash / update the firmware to the wemos d1. it
may ship with NODEMCU or AT commands.
For
help using python pip install and packages
https://packaging.python.org/installing/
Install
Python.
This guide uses 2.7 as of the writing of this install. This is
installed on the PC you are using. Do not use python 3 .
Make sure that it installs / registers itself in the local path so that
you can use the reguar “cmd” prompt. Else it might cause issues.
If things don’t work restart.
Then
open the python command line

Install
esptool from the python command line.
Help:
https://github.com/themadinventor/esptool
Commands

Pip
install esptool

If this command does not work, then you need to figure out how to get
python installed properly. You should be able to use the windows
terminal for this command.
Try restarting



Here
are the esptool github details if you need to do it manually, or refer
to instructions.
https://github.com/espressif/esptool
using
esptool
Commands

Esptool.py
-h
Shows
all available commands
esptool.py
–port COM6 –baud 115200 read_flash 0x0000000 4096 dump.dmp
Reads
out the first 4096 bytes to a file called dump to the current director
(c:/users/jhavell)

View
hex dump file using a hex capable editor (notepad++ with hex edit
plugin installed


Alt
method… use the GUI for esp8266
Windows
use nodemcu-flasher (https://github.com/nodemcu/nodemcu-flasher)

under Win32
From <https://forum.micropython.org/viewtopic.php?t=2166>

Clear
the esp8266, install image.
From windows Cmd prompt
:
Commands

Esptool.py
-h
Shows
all available commands
esptool.py
–port COM6 –baud 115200 erase_flash
Erases
the flash
<<esp8266-20161110-v1.8.6.bin>>
Download (http://micropython.org/download#esp8266)
and then copy the image file to the working drectory
esptool.py
–port COM6 write_flash -fm dio -fs 32m -ff 40m 0x0000000
esp8266-20161110-v1.8.6.bin
Flashes
the new image. The image is in the directory that you are in so in this
case c:/esp/lfasfile.bin

(optional… dum it again and verify the memory is all ff ff ff ff)



Testing
to see if it installed.
Check device manager for com port – Open com port
Open Putty (serial / console software) settings
Connect using (usb) serial console
115200 / 8 / no parity /1 stop/no flow ctl
Should
show up on wifi. Don’t connect yet.


You
will now be using the Putty Terminal to type commands.
This is called the REPL (Read Execute Python Language)
Once you open the connection:
Hit the Enter key at the cursor and wait for the prompt >>>
Try the hello world program
Commands

Print
(“Hello World”!)
Returns
hello world mesage
Import
esp
Imports
esp
Esp.check_fw() Checks
firmware.

If the last output value is True, the firmware is OK. Otherwise, it’s
corrupted and need to be reflashed correctly.
From <https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html>



Now
lets set up WEBREPL so that we can do this from a browser
commands

Import
webrepl_setup
Imports
the repl setup
Enable
and Set the web console password and then reboot

After a fresh install and boot the device configures itself as a WiFi
access point (AP) that you can connect to. The ESSID is of the form
MicroPython-xxxxxx where the x’s are replaced with part of the MAC
address of your device (so will be the same everytime, and most likely
different for all ESP8266 chips). The password for the WiFi is micropythoN
(note the upper-case N). Its IP address will be 192.168.4.1 once you
connect to its network. WiFi configuration will be discussed in more
detail later in the tutorial.
From <https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html>
Restart

[redacted]
[redacted]

The
Wifi connection of the device is

SSID Wifi
password
MicroPython-xxx micropythoN
IP
address
192.168.4.1

There is no webpage. It will go nowhere. You can only connect by
WebRepl, for now

Next,
we install the webrepl client on your Computer.
Here is an example of what it would look like once installed. You could
use this if your computer is hard wired or connected to the same wifi.
Otherwise, we will install this on your local machine.
Functional example:
http://micropython.org/webrepl/
Install it locally using this link
https://github.com/micropython/webrepl
Extract the files to a folder
Open the html file
Click the connect button
Enter the password you setup earlier of the serial console



Play
with the simple LED on the board
Commands
>>> import
machine
>>> pin
=
machine.Pin(2, machine.Pin.OUT)
>>> pin.high()
>>> pin.low()
From <https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/repl.html>

You
cannot simply copy and paste code into the repl console. It will throw
errors.
To enter a special “paste mode” hit
CTRL E
This will allow you to paste in chunks of text.
Use CTRL D
to exit this mode and execute the code as entered
https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/filesystem.html
The
code you enter at the REPL does not persist past reboot unless you save
it to a file. Say for example the entered the led toggle code above.
After unplugging and re-pugging in the code, you cant call the toggle
function. If you have your board connected over serial and hot the
reset button, you will see it reload in the console window.
To have your code persist, you would need to start creating files to
make the code permanent.
To view the files on the esp8266 , type the following:
Commands

Import os
Os.listdir() This
is like the “dir” or “ls” commands on a computer
Os.mkdir(‘cats’) Makes
a folder called cats
Os.rmdir(‘cats’) Deletes
the folder cats
Os.remove(fine.txt) Deletes
a file called fine.txt

Additionally, you can upload a file from your computer using the
webrepl console.
3.3. Start up
scripts

There are two files that
are treated specially by the ESP8266 when it starts up: boot.py and
main.py. The boot.py script is executed first (if it exists) and then
once it completes the main.py script is executed. You can create these
files yourself and populate them with the code that you want to run
when the device starts up.

From <https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/filesystem.html>



Esptool.py
-h
Shows
all available commands


This is a test post

November 18, 2016 by · 1 Comment
Filed under: Blog 

This is some stuff ND SOME THINGS LJSKLJSADFKLJSDLKJSDF


on

 
 


 
 


Disable OneNote activity notification emails

July 27, 2016 by · Leave a Comment
Filed under: Blog 

Somewhat recently, Microsoft automatically enabled notifications for all of my onenote notebooks. I was on vacation in Scarborough, Me recently, and the notification emails drove me nuts! It really is a nice idea, but as I am in my onenote all day, deleting emails saying “Here’s a summary of recent activity in your notebook” is not exactly how I want to spend my free time.

I also happen to have multiple onedrive accounts, so when I am working in my own shared OneNote, it appears like someone else is making changes.

 

The fix is very simple.

Part 1. Fix the problem.

  1. Click the update notification settings link at the bottom of one of those annoying emails.
  2. Disable / Enable notification for your desired OneNote Notebook, or disable them all.

update notification settings

 

onenote online notebook notification settings

 

 

Part 2. Prevent Future Outbreaks.

  1. Log in to your personal onedrive account (the one where the onenote notebook is located
  2. Go to options > Notifications
  3. Uncheck the box for “someone makes changes to files I shared


 



 

 

 

ta-da, No more emails.


Annoying windows 10 notifications

May 19, 2016 by · Leave a Comment
Filed under: Blog 

Alternative title: How you can still use your windows 10 pc and stay sane.

I hate notifications on my pc.

Traditionally, the audio clips Microsoft “designed” for notifications have been the most annoying creations possible. The new visual notifications are also something dredged from the lowest swap. Combined, these will drive you insane!

Microsoft Spoiler: Go to “Notifications & Actions” settings, then “Show notifications from these apps”.

Turn off the “Send to OneNote Tool”.

From <http://answers.microsoft.com/en-us/office/forum/office_onenote-onenote_2013/new-onenote-screen-clipping-notification-appears/5ef7a417-9c0f-450a-830c-f7f04aefc49a?auth=1

Disable notifications for specific apps:

Depending on your settings, OneNote notifies you EVERY TIME you take a screen clipping with an audio and visual notification.



The fix is easy. Search for notifications and turn them off the onenote tool.




Blogging directly from OneNote

May 19, 2016 by · Leave a Comment
Filed under: Blog 

Alternative title: One easy trick bloggers don’t want you to know!

Writing blogs does not have to be an arduous process. The number one nuisance for me is saving and uploading images. With OneNote (desktop), that problem is eliminated, as images are uploaded to your blog automatically when you post directly.

It only takes a few clicks to set up (assuming you have already set up a blog or website). Write up your article, insert your photos, and click send to blog!


You will be presented with a screen asking what provider you are using. Blogger, wordpress, and sharepoint are the top three supported platforms.


After that, simply type in your website in place of the carots and enter your credentials. (Don’t worry if you get an error, just check your spelling and try again… it took me 4 tries to realize I typed my own website address wrong.)


Once you are connected, you will be presented with a Word document containing your post, allowing one final look before you release it to “the cloud”. Find the publish button at the top left.

I like to upload my articles as a draft first, as there can be a few spacing and formatting issues that are not obvious from within OneNote / Word.


From there, simply log in to your blog, review for formatting and do a final check of links and spelling, and publish!

Happy Blogging!

One lazy trick the IT guy uses to fix your computer

April 5, 2016 by · Leave a Comment
Filed under: Blog 

Catchy internet marketing titles aside, this article shows you how to use msra.exe to remotely connect to computers that you control.

Tired of walking through the snow and rain to help with simple helpdesk requests?

Behold the power of Remote Assistance, built right into windows! This feature can be implemented for your environment, assuming that you are using Active Directory and Group Policy with your windows 7/8 environment. This allows you (or your minions) to remotely offer assistance to a user, initiating an “unsolicited” interactive remote desktop connection, with the option for you to request control of their machine. This does not, however, allow you to force remote control of the user’s computer. (There used to be a trick for Windows XP, but it does not work with windows 7/8)

Requirements:

  • The computer is connect to a windows domain that you have control over.
  • You / the helper must have domain credentials with local admin permissions to the remote computer.
  • You must be a domain admin, or have rights to create and manage Group Policy Users and Groups.
  • You may need to configure additional GPO settings for windows firewall and UAC

 

Step 1 – (for you, the helper)

  • Create a shortcut to C:\Windows\System32\msra.exe /offerra

Step 2 – (on your Domain)

  • Create a group that will be allowed to initiate connections.
  • Example “Offer Remote Assistance Helpers”
  • Add users to the group who will have permission to remotely assist others.

Step 3 – create a new GPO in an OU containing computers, called “Remote Assistance Policy”

  • Edit the GPO for Computer Configuration.

Step 3.1

  • Computer Configuration > Policies > Windows Settings > Security Settings > Restricted Groups
  • Right click/ Add Group
  • Type in or Browse for the Active directory group you created above.



Step 3.2

  • Go to Computer Configuration > Administrative Templates > System > Remote Assistance and click Configure Offer Remote Assistance.
  • Enable the policy
    • Permit remote control of this computer using “Allow Helpers to remotely control the computer
    • click Show… next to Helpers
    • Enter the names in domain\user or domain\group format.
    • Enter the group name you created earlier


Or in 2012 R2, is is Configure Offer Remote Assistance


Step 3.3

  • In the same settings folder, enable Solicited Remote Assistance
  • This setting may also be found under

    • Computer Configuration > Administrative Templates > System > Remote Assistance and click Solicited Remote Assistance.



Step 3.4

  • Go to Computer Configuration >Administrative Templates> Windows Components >Remote Desktop Services>Remote Desktop Session Host>Connections
  • Enable “Allow users to connect remotely using Remote Desktop Services”


Step 4

  • Apply this GPO to target computers. This can be done at the root of the domain, or under each OU, depending on desired deployment strategy and security considerations.

Step 5 

  • Perform a Gpupdate on server and clients and test to see if the settings work.

Step 6

  • When a user asks for help, launch the msra from the icon using the shortcut you  created (C:\Windows\System32 msra.exe /offerra)

Testing:

On your PC, launch the new icon


Enter the Computer Name and click next


The user will be prompted with the following:


Once the user clicks Yes, you will see the following.

Notice their desktop image has gone black. This is to preserve network bandwidth for smooth operation. The background will be restored once the support session ends.


You can select the “Request Control” screen


Which prompts the user for permission once again.


 (Tell the user to ignore the checkbox for UAC, unless the user you are helping is a local administrator on their PC. If they do not have local admin rights, they will get a popup asking for credentials, and you will get a black screen with an pause icon. Alternatively, look here)

Once you are done, you or the user may close the Windows Remote Assistance box to end the session!

Happy HelpDesk-ing!


Light up musical Christmas Card

December 29, 2015 by · Leave a Comment
Filed under: Blog 

Three days before Christmas, just as I was falling asleep, I had a vision of a led Christmas tree card. I imagined it would have a number of charliplexed LED’s blinking in a decorative fashion. I had a few ATtiny85 microcontrollers on hand from prior projects, and decided to give it a go.

First off came the experimentation with the Charliplex circuit. I have not played with charlies in a while.  A quick google search revealed some interesting sample code specifically written for the ’85. It has also been a long time since I used my ISP programmer, so I needed a quick reference of the pinout diagrams, for and the 6 pin ISP programming connector and the ISP pins on the ATtiny.

First off was locating some spare parts:

  • 5mm Red and Green LEDs
  • Atmet Tiny85
  • Jumpers
  • Breadboard
  • USBTinyISP programmer
  • Small flat speaker
  • momentary push button

Reference Code used:



The ISP Connections:


Once the ISP Pins were plugged into the micro with jumpers, it was time to program the ATTiny.

Step 1 – Upload Bootloader and select ATtiny85 board, 1 mhz.

Step 2 – Upload simple “Blink” Program

Step 3 – use sample Charliplex code and LEDs


A few quick jumpers on a breadboard yielded some blinkenlights.


First, we try out the sample Charliplex Code

Video – Charliplex code sample

Next, we locate some code that can play back simple tones using a single pin of the ATtiny.

Connecting the speaker is simple


Video: a simple Chromatic scale

 

Next was determining what notes sounded like Christmas Time Is Here from Charlie Brown Christmas.

I played around with a keyboard to find simple tones (not chords) that sound similar to this tune.

To my untuned, musically challenged ear, the beginning sounds somewhat like A, F , F, D, D.

To get the timing right, I added a new “note” called Z which results in an inaudible frequency when played.


I included note Z to add delays between notes.


The final result sounds like this

Video: Christmas Time Is Here

Because code generated using the Arduino IDE is single threaded, you can only play music or flash LEDs using the above code, not both at the same time. Also…this was 2 days before Christmas, I simply did not have enough time to figure out how to do it the right way. I opted for the “hacky” solution, simply alternating between led lights and tunes. Alternativly, I did experiment with two chips, one playing the tunes and one flashing the lights, as seen in the following video.

Video: two AtTiny 85 chips

Next, I assembled the basic card structure ( a Christmas Tree with LEDs) and wired up 4 pairs of LEDs, arranged with the reverse polarity of its sibling.


 

Each row has two LED pairs. These pairs will be charliplexed to 4 pins on the micro.

 

charlieledschristmas


The hookup is roughly as follows for each pair, plus one single LED.


And the messy wiring


I added a simple momentary push button switch to connect the 3v lithium cell to power the circuit. I taped a penny behind it for rigidity.


Finished product – “Christmas Time is Here” with LEDs

 

Mom loved it.

 

Instructional: Blink an RGB LED with Arduino

December 1, 2013 by · 1 Comment
Filed under: Blog 

When I was at the World’s Maker Faire in NY this past fall, the kind people at Sparkfun gave me several free Arduino’s and WS2811/ws2812 RGB LED breakout kits to give away.

This is a very brief collection of resources needed to get  new users started using a programmable RGB LED. The beauty of these units is their ability to be chained together.

Take a gander at the goods:

Ws2811 / WS2812 RGB Breakout Board


This is actually a prototype board with an Atmel Mega82U

Sparkfun “Arduino Compatable”

 

 

 

 

 

 

 

 

 

 

 

 

And this is what the end product of this tutorial will look like.

Ooooooo the blinky.

WS2811 Breakout board with Arduino


 

 

 

 

 

 

 

 

 

 

 

Setup:

High level overview:  You will be installing the Arduino IDE, copying the neopixel library folder into the arduino libraries folder, then opening the example project file and upload it to the arduino.

You will need the following items:

 

Procedure:

#1
Download and install the latest Arduino environment.


 

 

 

 

 

 

 

 


 

#2
Download the Neo Pixel library.


#3

Install the library by copying it to the correct folder for your Arduino IDE. This varies by operating system. The following instructions are for PC.

Mac holds its files in a different location. Instructions for installing a library on Mac are located here.

Linux users probably won’t be reading this article.

 

For Windows:
Locate your downloaded .zip file and extract it to a folder.



 

#4
Open the folder and change the name of the folder to Adafruit_NeoPixel, removing the  -master, otherwise you will receive an error.


Copy the folder and Paste it into your libraries folder. (My Documents/Arduino/libraries)


#5
Close and re-open the Arduino program



If you receive the following message, you missed step #4


 

 

#6

If all goes as expected, you should be able to open the “strandtest” NeoPixel example code from the File> Examples> menu.


 

You should see the following code: 


 

#7
I would like to call your attention to the comments in the code. They tell you two pieces of information you need to update before uploading your code.
The first is what pin the LED breakout will be connected to.

This is the first line after the include statement:

#define PIN 6

(btw, that is how you use a library, you have to invite it to the party by using the #include.)

We are going to go ahead and hook up the DI pin of the breakout board to digital pin 6. We are going to keep it at pin 6 in the code. If you want to use a different pin number, this is where you would change it.


On the breakout board – DI for Digital In. DO is for digital out.


 

#8
We are going to physically connect the DI (Digital In) to Pin 6 (digital pin 6) on the Arduino.




#9
We will also set up the number of LEDs. In this instance we only have 1 of these breakout boards connected. If we had more than 1, they could be connected in series.

Change this single line of code from a 60 to a 1

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

#10
Verify that the wiring and environment to ensure we do not perform a smoke test.

Connect the USB cable. 
Tech Tip: If this is your first time connecting the Arduino, your computer may have to load or install a driver to allow your computer to communicate with the Arduino. This driver should be included in the Arduino IDE. If you have problems getting the board to be recognized, you’re gonna have a bad time. See here and here for additional troubleshooting and information. Oh and hereCommunication between the Arduino (Atmel Mega328) and the computer is done over a serial connection. Most Arduinos with a USB connection utilize some form of USB to serial adapter. The board I am using in this particular example uses an FTDI chip to do the USB>serial communication for us. Other boards may use another AVR microcontroller or even implement serial directly in code using v-usb.

 

#11
Click tools > Serial Port and select your COM port.


I tested COM3 – no go.

COM8 is our man


#12
Select the board type from the Tools >Board menu. The Sparkfun Redboard that I am using is Arduino Uno compatible.


#13

Click upload.


If it works you will see some LEDs on the Arduino flashing. On mine it was the red and yellow RX /TX LED’s.



Wonder of Wonders, it works!

Prototyping is fun, but we can do better.

 

 

 

 

 

 

 

 

 

 

Troubleshooting:

If you get errors like this when uploading, go back to step #11. You may have to go back and select a different COM port or a different board.




If your board had a few flashes of lights but no activity on the breakout board, double check the 5v, ground, and DI wire are securely connected and plugged in to the correct pins on the Arduino.

 

Going Further:

-Connect multiple WS2811’s in Series

-Connect multiple WS2811’s in a matrix

Alternative Libraries

OCTOWS2811 by PJRC

Neopixel by Adafruit


 

 

This post was composed and uploaded from Microsoft OneNote 2013

IP Cameras

July 11, 2013 by · Leave a Comment
Filed under: Blog 

So… I finally purchased an Ip Camera, courtesy of the cheapest eBay listing I could find.

It’s a Foscam FI9818W. Pan and Tilt, wired and wireless networking, 2 way audio and Infared illumination. Pretty slick for $45. If only it had relay outputs.


So I plugged it in and got it talking to my network. Here it is looking at the wall.


 I also got it working with the Foscam App for iOS. 2-way audio built in!



Firmware is a bit old… Lets update that.

It also has motion detection and can automatically email photos or upload them to an FTP server.

I set it to email me a few snapshots when it detects motion outside of the regular business day.



Hi

Wave for Mr Blurry Cam!


This post was composed and uploaded from Microsoft OneNote 2013 

Arduino – Displays

January 18, 2011 by · Comments Off on Arduino – Displays
Filed under: Arduino, Projects 

Picked up my first display for my Arduino Duemilanove.

I saw an article over on HackaDay and it reminded me of a previous submission related to a custom job done up overseas in a VW TDI  to monitor various bits, mounted inside a dash button!

Owning a VW TDI, and wanting to monitor EGT, boost, temps, etc motivated me to at least investigate how difficult it is to interface the Arduino with a full color RGB LCD.

After a quick Google search  for “RGB LCD Shield for Arduino”,  I ran across the following product from NKC Electronics.

65k RGB LCD Shield from NKC Electronics - KIT

After a little playing I got the board soldered up and displaying the demo images and some custom text. The arduino demo code library was written by Henning Karlsen for NKC, and is released under the GNU Lesser General Public License. Really easy to assemble, and well documented code.

I did have a little bit of difficulty getting the full Demo code to run, but the bitmap code worked great with a simple upload.

Next Page »