DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • IoT and Cybersecurity: Addressing Data Privacy and Security Challenges
  • Next-Gen IoT Performance Depends on Advanced Power Management ICs
  • How Can Developers Drive Innovation by Combining IoT and AI?
  • A Deep Dive Into Firmware Over the Air for IoT Devices

Trending

  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  • Tired of Spring Overhead? Try Dropwizard for Your Next Java Microservice
  • How to Use AWS Aurora Database for a Retail Point of Sale (POS) Transaction System
  • Exploring Intercooler.js: Simplify AJAX With HTML Attributes
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Mongoose: More Than an Embedded Web Server

Mongoose: More Than an Embedded Web Server

Mongoose is a surprisingly small, easy-to-embed, and powerful open-source server project.

By 
Deomid Ryabkov user avatar
Deomid Ryabkov
·
Updated Feb. 11, 23 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
7.0K Views

Join the DZone community and get the full member experience.

Join For Free

ESP8266 is all the rage these days. It's a very affordable single-chip WiFi solution with a fairly capable CPU core on board. It came onto the scene in 2014 and made a pretty big splash, especially in DIY circles. It is one of the primary platforms supported by Mongoose OS, our IoT solution, but what if you want just Mongoose Embedded Web Server? The answer is — of course. We prepared a simple example to help you get off the ground quickly. We’ll show you how to use Mongoose to create a simple webserver running on ESP8266.

First, a quick refresher on setting up the ESP8266 build environment. This is not specific to Mongoose, so feel free to skip it if you have everything ready.

You will need:

  • One of the ESP8266 modules (we presume you already have that)
  • A Linux machine running Ubuntu (a VM will do)
  • The RTOS-based SDK — clone this repo
  • GCC compiler toolchain
    • Download xtensa-lx106-elf.tar.bz2 from this public folder.
    • Follow the instructions in step 4 of the README.

Once you have the toolchain installed (xtensa-lx106-elf-gcc and make commands should work), clone the latest Mongoose repository and go to the examples/ESP8266_RTOS subdirectory.

Once there, and assuming the toolchain has been installed correctly, you should be able to build it with the following commands:

Shell
 
$ export SDK_PATH=/opt/ESP8266_RTOS_SDK  # change this to your SDK location$ export BIN_PATH=./bin; mkdir ./bin$ make clean; make BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=qio SPI_SIZE_MAP=0[...]!!!SDK_PATH:/cesanta/ESP8266_RTOS_SDKBIN_PATH: ./binNo boot needed. Generate eagle.flash.bin and eagle.irom0text.bin successully in BIN_PATHeagle.flash.bin-------->0x00000eagle.irom0text.bin---->0x20000!!!


With firmware built, it is now ready for flashing. We recommend you use esptool for this, but any other flashing tool will do. For esptool, the command line will look like this:

Shell
 
$ esptool.py --port /dev/ttyUSB0 --baud 230400 \    write_flash --flash_mode=qio --flash_size=4m \    0x00000 ${BIN_PATH}/eagle.flash.bin \    0x20000 ${BIN_PATH}/eagle.irom0text.bin \    0x7e000 ${SDK_PATH}/bin/esp_init_data_default.binConnecting...Erasing flash...Took 0.58s to erase flash blockWrote 35840 bytes at 0x00000000 in 1.8 seconds (157.5 kbit/s)...Erasing flash...Took 2.02s to erase flash blockWrote 301056 bytes at 0x00020000 in 15.4 seconds (156.7 kbit/s)...Erasing flash...Took 0.11s to erase flash blockWrote 1024 bytes at 0x0007e000 in 0.1 seconds (163.5 kbit/s)...Leaving...


After this, you should see a “Mongoose” WiFi network appear — the example sets up an AP. Use the password “Mongoose” to connect and navigate to http://192.168.4.1/, and you should see a “Hello, world” greeting page — served by the event handler defined in user_main.c.

And that is all for today. This example only demonstrates a web server, but you have all the power of the Mongoose multi-protocol networking library at your disposal (except file serving, because ESP does not have a filesystem by default).

Happy hacking!

Mongoose (web server) IoT

Published at DZone with permission of Deomid Ryabkov, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • IoT and Cybersecurity: Addressing Data Privacy and Security Challenges
  • Next-Gen IoT Performance Depends on Advanced Power Management ICs
  • How Can Developers Drive Innovation by Combining IoT and AI?
  • A Deep Dive Into Firmware Over the Air for IoT Devices

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!