top of page
Writer's pictureBen Jabituya

Lucid dreaming with the Circuit Playground Express



History of Lucid Dreaming devices


Stephan LeBarge and the Lucidy Institute were pioneers in developing devices to aid lucid dream induction and they were best placed for this because of the wider remit of the Lucidity Institute’s study of dreaming and the number of practicing lucid dreamers to test and develop hardware with. The DreamLight mask was developed in the early 90’s, not many of these were made available and they were very expensive. The NovaDreamer was the more commercial device that was produced following the studies with DreamLight/Dreamlink, I don’t know what they retailed for originally, they have never been cheap though and they are mega rare to find now.

The basic principle of these devices was to detect eye movement using IR and then cueing the user with a colour LED that would flash at set intervals, these flashes would be visible to a wearer within a dream state. This biofeedback mechanism had been proven to work with DreamLight and I’d argue that these masks, despite being nearly 30 years old, have never really been improved upon. There have been products that detect REM using brainwaves and there’s been some interesting studies recently that will no doubt lead to more of these – however to cue a user in a dream state, the best we’ve got in terms of biofeedback is still signalling via light, so I feel eye movement detection is still a more efficient and cost-effective approach given that you’ll still need some kind of hardware over the eye.


There was a company in Europe that developed the REM Dreamer & REM Dreamer Pro that used similar hardware and techniques that was basically a copy of the NovaDreamer, and these continued to sell after the NovaDreamer was discontinued in ~2004, I bought one of these at the time. The mask, despite being actually more comfortable than it looks, is still not actually comfortable. I can vouch that it detects eye movement and cues correctly but in most cases it would either wake me up from a dream state or it would just cue when I’d open my eyes in the morning. The latter kinds of issues would be easy to offset by adding an accelerometer and/or gyro to detecting face movement and thus wakefulness. Given that you are effectively paralised during dream state, if the device briefly assessed for motion, it could then make a better decision as to whether to cue a wearer or not.


Circuit PlayGround Express


The CPX is one of Adafruit Industries best selling products not least because it is such a versatile little dev board. It’s been updated several times and one of the newer features is support for CircuitPython, which makes development cycles much quicker where you just have to copy code to a single file for your application to work – no need for development environments and setting up. The drawback vs compiling as an Arduino sketch is I guess slower execution speeds and memory usage limitations – the code for this project is pretty much the very limit of how many lines you can have at around ~250 so you do have to think carefuly about the code’s workflow.


From all the features documented, one that isn’t detailed is the ability of the board to perform proximity detection using IR. The board has a built in IR LED and a sensor with some basic hardware that makes it possible to read raw data but it’s implementation is such that there are a lot of variables that make it difficult to accurately document an ideal method of taking proximity measurements. Despite it not being documented, Ladyada put a video on Youtube of an approach to get proximity detection working. The approach described was conducted using normal Arduino code and sketches and Adafruit’s forums suggest that it’s not possible with Circuitpython given it’s slower execution speed – but it is. The caveat to using CircuitPython is it appears you need to keep the IR on for longer than you would if you did this as an Arduino project, which may not be great for the lifespan of the LED. I haven’t tested faster speeds but it might be possible to run it quicker and thus extend the LED lifespan – discussed in more detail in the GitHub project doc. Having tested different speeds I managed to get proximity detection working using IR, I just needed to test how effective it is at detecting eye movement.


The placement of the sensor and LED and the LED’s field-of-view appear to work well for REM detection, I've added a small bit of tape around the IR LED for better seperation from the sensor but I'm not sure it's required. Once I’d modified a sleeping mask to hold the board and test by moving my eyes – I could see and chart the increase in variability compared to when stationary:

With eye movement detection now sorted, the next stage is to detect face movement and wakefulness – the board has a built in accelerometer so again, with no additional components required, this is easy to do and this time there’s no hacks needed.


The board features 10 RGB NeoPixels and these can be used to cue a wearer in a REM state. These can be programmed in a number of ways but I’ve kept the Rainbow Cycle that is part of the initial example code file that comes with the OS when you install it – it’s pretty cool. Most other devices just use a standard red LED as they're the cheapest you can get and the thought that most light appears red when your eyes are closed given the blood vessels it passes through but I can definitely perceive variations in colour with the NeoPixels. The way I’ve placed the board on the mask means that the light is scattered indirectly rather than straight towards your retina as well - if I find this not to be effective I can just cut more of the mask and expose the Neopixels more.


The sleeping mask I used to fit the board to looked ideal for this with thin eye socket areas to cut away but I don't like the material so will probably find another mask to attach it to and that's easy to do because the mounting is modular as you can see in the video.


Full code on GitHub


Other interesting links (there’s more project specific links on GitHub)

Stephen LeBarge’s original paper on DreamLight:

Validity Established of DreamLight Cues for Eliciting Lucid Dreaming

NovaDreamer Manual:

1,961 views12 comments

Recent Posts

See All

12 commentaires


Bryan Bennett
Bryan Bennett
16 juin 2022

I recently bought the Muse S (Gen 2) EEG and have been using it to monitor and record sleep stages throughout the night. I also recently used the Bluemuse app (MUSELSL on Windows 11 PowerShell) to view the TP9, AF7, AF8 and TP10 brainwave patterns streaming from my Muse S. I am also very interested in lucid dreaming. A few years ago, a friend and I built a REM detection device that used a finger tip pulse detector (https://pulsesensor.com/) and a micro-accelerometer (both connected to an Arduino microprocessor) to reliably detect REM sleep. I then experimented with different stimuli to see which ones would manifest in my dreams and possibly induce lucidity. I tried stimulating the median nerve with…

J'aime
Ben Jabituya
Ben Jabituya
17 juin 2022
En réponse à

Hi, Bryan your project sounds interesting, I'll check some of that out. I am working on a software product that uses LSL with the Muse. At the moment I'm able to stream Muse data and predict sleep stages in real-time or basically every 3-5 minutes. I haven't worked in a REM alarm yet but it will be audio based as you'll need a PC running anyway for LSL. If you look at my latest blog post it shows a brief view of what it will look like: https://www.majorinput.co.uk/post/arduino-based-eeg-sleep-monitoring

J'aime

scottveron03
scottveron03
12 juin 2021

Hi, cool project. Were you successful in inducing lucidity with this in yourself?

J'aime

contact
18 avr. 2021

Hi. This is a great project and I got already all together. Now, I have only one problem. code.py output:

MemoryError: memory allocation failed, allocating 996 bytes

Dear Ben, did you experienced this too, and do you have a shorter version of the code?

I tried to get the code transferred into a .mpy file, but this was not enough.

Hope you, or someone else can help a newbie like me :-(

Cheers

J'aime
Ben Jabituya
Ben Jabituya
20 avr. 2021
En réponse à

As per topofthestack's note, the easiest option is to remove code until it fits, maybe some of the print statements - the libararies that are imported at the top of the code.py file have probably increased in size since I made this and there is a limit on code length overall. The other option is to download an older version of the firmware as it would have been smaller at the time but I'd advise against doing that or else keep it as a last resort because it's better to have the latest on these devices most of the time.

J'aime

topofthestack
17 févr. 2021

Thank you Ben, I got it working following your advise to remove some lines of code. Basically took out wheel() and changed rainbow_cycle() to only use RED.

Also increased the wait time passed in as signal that I'm dreaming, to make it more like the NovaDreamer signal (which I've had success with in 2007.)

Should be fun!

J'aime
Werner Schnitzler
Werner Schnitzler
30 juin 2023
En réponse à

Would have to dig deep in the mess that is my PC ..


Have you tried this?


"Take out wheel() and change rainbow_cycle() to only use RED."

J'aime

Ben Jabituya
Ben Jabituya
08 févr. 2021

Hi, if you've followed the README and copied all the files it would be hard to say where the problem is...are you keeping the circuitplayground connected to the PC and seeing anything coming up in the terminal/Mu? If you've copied the code over but aren't using a terminal or something like Mu, I'd suggest doing that first and then confirm if anything get's printed out as there's a few times where the program outputs info that helps confirm thing are working ok.


https://learn.adafruit.com/welcome-to-circuitpython/kattni-connecting-to-the-serial-console

J'aime
bottom of page