Smoke signals have been used in a variety of contexts throughout history. I believe smoke signals were used along the Great Wall of China and by Native Americans, but I'm not qualified to say anything about those. What I am familiar with is how they were used by sailors and pirates during the Age of Sail.
It's a trope in movies that when people are marooned on a desert island they make smoke signals to alert passing planes or boats. This is basically a good idea. If you ever find yourself marooned on a desert island, you should probably try to do that. Smoke is a very good way to attract attention over very long distances and show that there is a human wherever it's coming from. Still, historically people often didn't attempt to make smoke signals when they were marooned on islands circa 17th-18th centuries because those were very dangerous times and they didn't necessarily want to attract attention from the wrong people (pirates, enemy nations, etc.). Passing ships could also be less likely to approach smoke signals since they feared being lured into a trap or they assumed it was natives as it often was. When the famous castaway Alexander Selkirk was marooned on the Juan Fernandez Islands off the coast of Chile from 1704-1709, he was constantly on the lookout for ships but he would never light a smoke signal because he didn't want to attract the attention of Spanish ships who would capture and imprison him as a privateer or possibly execute him. Even despite his precautions, they did spot him and chase him inland several times and he once only barely avoided detection when they urinated under a tree he was hiding in. Other times, when castaways had less reason to fear being discovered they would indeed send up smoke signals. Two Dutch mutineers marooned on the west coast of Australia were instructed to keep a keen lookout for ships at certain times of the year and "give suchlike signs as shall appear to be done with purpose, be it with smoke or otherwise" (Voyage to Disaster, 230)
Other times smoke signals were used more systematically when sailors had prearranged to communicate that way. In 1629, shipwrecked sailors and soldiers on the Houtman Abrolhos Islands off the west coast of Australia used prearranged smoke signals to communicate between the number of small islands a few miles apart. When a small party was sent off to some distant islands to search for water, they were told to send up smoke signals if they were successful. There still in fact appear to be a few fire beacons on this exact island along with some other makeshift structures these men made. The rocks were evidently piled up in that way to contain the fire and send up a more concentrated plume of smoke. Later when a rescue ship came and began salvaging from the wreck, which was quite difficult because of stormy weather, they again communicated as best as they could between the islands using smoke and fire as well as other means, but it doesn't seem to have been anything very complex or sophisticated. The captain, Francisco Pelsaert, writes in his journal that when he sensed a storm was coming, he frantically "gave all possible signs with fires, flag-waving and other means as well, so that the yawl should return quickly." Apparently any kind of complex "Morse code" type messages were impractical.
A more exciting use of smoke signals occurred when English and French buccaneers were attacking Spanish towns along the Pacific coasts of Central and South America in the 1680s. One of these buccaneers named William Dampier left behind a journal in which he describes this. Dampier writes that whenever a party of buccaneers left their ships to scout the enemy countryside they would always either "order a certain Place of Meeting, or else leave them a Sign to know where we are, by making one or more great Smoaks." They also tried to do this to signal that they had successfully captured a town to those waiting in the ships. However, Dampier goes on to write that this nearly backfired disastrously when the Spanish found out about the signals from torturing prisoners and then tried to use it to lure them into an ambush:
...yet we had all like to have been ruined by such a signal as this, in a former Voyage under Captain Sharp, when we made that unfortunate Attempt upon Arica. ... For upon the routing our Men, and taking several of them, some of those so taken told the Spaniards, that it was agreed between them and their Companions on board, to make two great Smoaks at a great distance from each other, as soon as the Town should be taken, as a signal to the Ship, that it might safely enter the Harbour. The Spaniards made these Smoaks presently: I was then among those who staid on board; and whether the signal was not so exactly made, or some other Discouragement happened, I remember not, but we forbore going in, till we saw our scattered Crew coming off in their Canoes. Had we entered the Port upon the false Signal, we must have been taken or sunk; for we must have past close by the Fort, and could have had no Wind to bring us out, till the Land-Wind should rise in the Night. (Dampier, 175-6)
How is that for some pre-Enigma (pirate) code breaking?
Sources:
Voyage to Disaster by Henriette Drake-Brockman
A New Voyage Round the World by William Dampier